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

187
Views
Bot activities not show correct user in server

I have this bot project, so basically the bot will show you how much server they in, and show you how much member that on that server you currently in, is there a way to fix this since it always show 1 users (which is me probably) meanwhile there's like 400 people in the server I'm in.

Here's my code:

const { MessageEmbed } = require("discord.js")

module.exports = async bot => {
    console.log(`${bot.user.username} is now online!`)
    var activities = [ `${bot.guilds.cache.size} servers`, `${bot.users.cache.forEach(guild)} users!` ], i = 0;
    setInterval(() => bot.user.setActivity(`${PREFIX}help | ${activities[i++ % activities.length]}`, { type: "WATCHING" }),5000)
    


};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could try using <Guild>.memberCount. The problem is that your code currently only grabs the cached users, which apparently is only one.

Edit: Here as requested a code example:

const { MessageEmbed } = require('discord.js');

module.exports = async bot => {
    console.log(`${bot.user.username} is now online!`);
    let counter = 0;
    bot.guilds.cache.forEach(guild => {
        counter += guild.memberCount;
    });
    const activities = [`${bot.guilds.cache.size} servers`, `${counter} users!` ], i = 0;
    setInterval(() => bot.user.setActivity(`${PREFIX}help | ${activities[i++ % activities.length]}`, { type: 'WATCHING' }),120_000);
}

I did some more small changes... in general, don't use var, use either let or const. Also, you shouldn't be changing your status every 5 seconds since that's considered API spam. I changed your interval to 5 minutes instead which is more reasonable (but still a small number, if it doesn't matter too much for you I'd even set it to 10 minutes).

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!