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

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

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