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

116
Views
Filter out bots from member count in client status

I want to make my bot activity say "Watching + Member Count (not include bots)".

I did some steps, here is my code:

client.once('ready', () => { 
        setInterval(() => {
          targetGuild = client.guilds.cache.get('My Guild ID Here')
          client.user.setPresence({ 
            activities: [{ name: `${targetGuild.memberCount} Users`, type: 'WATCHING' }], 
            status: 'online'
            });
        }, 1000 * 60 * 5);
    
    });

The thing that I need is to set a filter that it calculate members only, not bots.

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

0

Use GuildMemberManager#fetch() to fetch all members, then use Collection#partition() to split the member collection into bots and humans. Use humans.size to display the user count as you intend. You can also Collection#filter() to filter the member collection to just the humans, however I use partition in this example to have access to both parties in one function call.

client.once('ready', async() => { 
   targetGuild = client.guilds.cache.get('My Guild ID Here');
   try {
      const [bots, humans] = (await targetGuild.members.fetch())
         .partition(member => member.user.bot);
      setInterval(() => {
         client.user.setPresence({ 
            activities: [
               { 
                  name: `${humans.size} Users`, 
                  type: 'WATCHING' 
               }
            ], 
            status: 'online'
         });
      }, 1000 * 60 * 5);
   } catch (err) {
      console.error(err);
   }
});
about 4 years ago · Juan Pablo Isaza Report

0

In discord.js v13 the member counting with bot filtering should look like this:

   setInterval(() => {
        const guild = client.guilds.cache.get('GUILD_ID');
          let humanMembers = guild.members.cache.filter(
            (user) => !user.user.bot
          );
          const channel = guild.channels.cache.get('CHANNEL_ID');
          channel.setName(`👤Member Count Test: ${humanMembers.size.toString()}`);
        }, 60000);
});

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!