Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
Discord js members loop returns only single user

I want to get all the users in my servers on ready of my discord bot so that I can add them to a database.

I have the discord privileged gateway intents all turned on. But I am only getting the id of a single user with the following code:

client.once('ready', () => {
    client.guilds.cache.values().next().value.members.list().then((members) => {
        members.each(member => {
            console.log(member.id)
        });
    })
})

I am sure I have included all the intent that would be necessary while creating my client:

const client = new Client({ intents: ["GUILDS", "GUILD_MEMBERS", "GUILD_BANS", "GUILD_EMOJIS_AND_STICKERS",
    "GUILD_INTEGRATIONS", "GUILD_WEBHOOKS", "GUILD_INVITES", "GUILD_VOICE_STATES", "GUILD_PRESENCES", "GUILD_MESSAGES",
    "GUILD_MESSAGE_REACTIONS", "GUILD_MESSAGE_TYPING"]} )

I dont know why it is giving id of only 1 member (owner) while the test server has 3 members including the bot.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

client.guilds.cache.get(guild_id).members.cache.map(member => member.id)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda