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

185
Views
Role Count not working properly discord.js

I tried doing a role count for a specific role with a role ID. My problem now is that the count isn't working properly. I gave 4 people the role and the bot is only counting one person with that role and I don't know why.

My Code:

case 'new':
   let roleID = "877984124483400480";
   let membersWithRole = message.guild.roles.cache.get(roleID).members;
   message.channel.send(`There are ${membersWithRole.size} People with the new Group on our discord`)
break;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I recommend fetching it because cache is unreliable.

case 'new':
   let roleID = "877984124483400480";
   const rolesCache = await message.guild.roles.cache.fetch()
   let membersWithRole(roleID).members;
   message.channel.send(`There are ${membersWithRole.size} People with the new Group on our discord`)
break;

Or it can be the intents. Check if you have server members intents and have GUILD_MEMBERS intent in the client options.

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!