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

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

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 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