Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda