Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
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 answers
Answer question

0

client.guilds.cache.get(guild_id).members.cache.map(member => member.id)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!