Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!