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

219
Views
Filter bots in counting server members using discord.js v13

I'm trying to create a variable that will store the user count of the message's guild id, but with no avail.

This is what I've got so far:

const guild = client.guilds.cache.get(message.guild.id)
var memberCount = guild.memberCount

It outputs the correct number of members but I'm not sure how to filter that amount so only bots will be excluded. I know this kind of question has been asked a many times on SO but the majority of the answers I've found would set the member count variable to 1, which I still don't understand why that happens.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Please note: You need the GUILD_MEMBERS intent enabled for this to work

const guild = await client.guilds.fetch(message.guild.id) // Fetch guild
guild.members.fetch().then(ms => { // Fetch members
  // Call reducer function, using ternary operator to count non-bots
  const nonBots = ms.reduce(acc, mem => member.user.bot ? acc : acc+1)
})
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!