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

63
Vistas
Guild members without bots always 1

I'm using

let real_members = interaction.guild.members.cache.filter((member) => !member.user.bot).size;

to get all members excluding the bots on a server, but this somehow always returns 1. (Slash command)

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Fetch all the GuildMember's first and access the returning collection, then sweep (remove) all the members who are bots.

let real_members;
interaction.guild.members.fetch().then(all_members => {
   real_members = all_members.sweep(member => member.user.bot);
});

console.log(real_members.size);

Ensure you have Intents.FLAGS.GUILD_MEMBERS included in your client's intents aswell as enabled in your Discord developer portal

Discord.JS Collection Utility Functions

about 4 years ago · Juan Pablo Isaza Denunciar

0

Maybe try using ".fetch" so:

interaction.guild.members.fetch()
.then ((members) => {
    const AmountOfMembers = members.filter((member) => !member.user.bot).size
}) 

CODE IS NOT TESTED

To be able to access it outside either define variable outside or turn it into a function and return the value.

function getMembers (interaction) {
    interaction.guild.members.fetch()
    .then ((members) => {
        members.filter((member) => !member.user.bot).size
        .then((Amount) => {
        return Amount
        })
    }) 
};


const AmountOfMembers = getMembers(interaction);

Just pass it your interaction.

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