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

56
Views
Guild members without bots always 1

I'm using

let real_members = interaction.guild.members.cache.filter((member) => !member.user.bot).size;

to get all members excluding the bots on a server, but this somehow always returns 1. (Slash command)

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

0

Fetch all the GuildMember's first and access the returning collection, then sweep (remove) all the members who are bots.

let real_members;
interaction.guild.members.fetch().then(all_members => {
   real_members = all_members.sweep(member => member.user.bot);
});

console.log(real_members.size);

Ensure you have Intents.FLAGS.GUILD_MEMBERS included in your client's intents aswell as enabled in your Discord developer portal

Discord.JS Collection Utility Functions

about 4 years ago · Juan Pablo Isaza Report

0

Maybe try using ".fetch" so:

interaction.guild.members.fetch()
.then ((members) => {
    const AmountOfMembers = members.filter((member) => !member.user.bot).size
}) 

CODE IS NOT TESTED

To be able to access it outside either define variable outside or turn it into a function and return the value.

function getMembers (interaction) {
    interaction.guild.members.fetch()
    .then ((members) => {
        members.filter((member) => !member.user.bot).size
        .then((Amount) => {
        return Amount
        })
    }) 
};


const AmountOfMembers = getMembers(interaction);

Just pass it your interaction.

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!