Skip to content
Advertisement

(discord.js) Problem listing all the members

function getMembers(serverId) {
    const server = client.guilds.cache.get(serverId)
    server.members.fetch({limit: 1})
        .then(console.log)
        .catch(console.error)
}

This function never returns anything. Can you help me?

Advertisement

Answer

As Cameron said in the comments you need to enable the GUILD_MEMBERS and the GUILDS intent from your Client constructer by listing it in the intents property of the Client Options like so

const client = new Client({
  intents: [
    "GUILDS",
    "GUILD_MEMBERS",
  ],
});
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement