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

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

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 Relatório

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