最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to fetch all members of a large guild discord.js - Stack Overflow

programmeradmin0浏览0评论

I am trying to fetch the ids of all members of a large guild. This guild has around 2000 people in it. I am using this:

const list = client.guilds.get("id"); 
list.fetchMembers().then(r => {

    r.members.array().forEach(r => {
    let userid = r.id        
    msg.channel.send(userid)
    })
});

It works for my test guild of 3 people but once I try it with the large guild, I get this error

(node:8632) UnhandledPromiseRejectionWarning: Error: Members didn't arrive in time.
at Timeout._onTimeout (c:\Users\Han75\Documents\bot\node_modules\discord.js\src\client\Client.js:436:7)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)

I know its because of a timeout. How do I stop this?

I am trying to fetch the ids of all members of a large guild. This guild has around 2000 people in it. I am using this:

const list = client.guilds.get("id"); 
list.fetchMembers().then(r => {

    r.members.array().forEach(r => {
    let userid = r.id        
    msg.channel.send(userid)
    })
});

It works for my test guild of 3 people but once I try it with the large guild, I get this error

(node:8632) UnhandledPromiseRejectionWarning: Error: Members didn't arrive in time.
at Timeout._onTimeout (c:\Users\Han75\Documents\bot\node_modules\discord.js\src\client\Client.js:436:7)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)

I know its because of a timeout. How do I stop this?

Share Improve this question asked May 1, 2020 at 12:36 Han75Han75 31 gold badge1 silver badge3 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 1

Assuming you're on the latest stable version (v12), you can use GuildMemberManager#fetch with no arguments to fetch all members of a guild.

发布评论

评论列表(0)

  1. 暂无评论