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

199
Visualizações
Can't return user total presence.status of Global

I want to retrieve all my users of all guilds where my bot is used at. What i need is a total(global) of these :

presence?.status == "offline")
presence?.status == "online")
presence?.status == "DND")
presence?.status == "bots")

well what i did is this and it returned 0 :

let userCount = message.client.users.cache.filter(member => member.presence?.status == "offline").size
    console.log("total",userCount)

If i want to return everyone as a total(global) that works normal:

let userCount = message.client.users.cache.size;
console.log("total",userCount)

if i do this i get them but seperate,i need a total.

client.guilds.cache.forEach((guild) => {

const total = guild.members.cache.filter(member => member.presence?.status == "online").size
console.log(total)
}

any idea how to do this? i'm on v13

regards

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Using forEach() might be a possible solution. We are going to use the increment operator (++). For example, something like this should work:

let userCount = 0;
client.guilds.cache.forEach((guild) => {
    Array.from(guild.members.cache.filter(member => member.presence?.status === 'online').values()).forEach(() => userCount++);
});

console.log(userCount);

Hoped this helped!

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