Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda