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

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

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