Reputation: 473
I need to get a list of all the members in a server. I tried
client.guilds.cache.get(message.guild.id).members.cache.array()
but for some reason, it only returned 2 users: me, and the bot, despite the fact that there are more than 2 members of my server. Is this the correct way of getting the users, and should this code work?
Upvotes: 0
Views: 258
Reputation: 723
Add this when declaring client
const client = new Discord.Client({ ws: { intents: [ 'GUILD_MEMBERS'] }});
Then turn on gateway intents in Discord Developer Portal
Then look for gateway intents
Note: Once you hit 100 servers it'll need whitelisting and some time to be approved / verified by Discord(Mine took about 3 months)
Upvotes: 1