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

343
Vistas
My discord bot not updating status when it joins a new server

My bot not updating when someone invites my bot to their/another server. I have to restart the code, then it is working. I want that my bot updated when someone invites in status.

My current code is:

PREFIX = <

client.on("ready", () => {
  console.log(`${client.user.username} ready!`);
  client.user.setActivity(`${PREFIX}help | ${PREFIX}play  ${client.guilds.cache.size} servers `, { type: "LISTENING" });
});
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It seems you want to update the bot's status whenever your bot joins a new server. Instead of using an unnecessary setInterval to check the cached guild size every X seconds, you could use the guildCreate event.

It emits whenever the client joins a guild, so whenever it fires, you can update the activity inside its callback:

// emitted when the client becomes ready to start working
client.on('ready', () => {
  console.log(`${client.user.username} is ready!`);

  client.user.setActivity(
    `${PREFIX}help | ${PREFIX}play | ${client.guilds.cache.size} servers`,
    { type: 'LISTENING' },
  );
});

// emitted whenever the client joins a guild
client.on('guildCreate', (guild) => {
  console.log(`${client.user.username} joined the ${guild.name} server`);

  client.user.setActivity(
    `${PREFIX}help | ${PREFIX}play | ${client.guilds.cache.size} servers`,
    { type: 'LISTENING' },
  );
});

PS: your client needs the GUILDS intent to be enabled

about 4 years ago · Juan Pablo Isaza Denunciar

0

You must update your status every X seconds. Your code that you are using right now just updated when the bot is ready.

To do this you must set a Interval to run the code every X seconds.

client.on("ready", () => {

    console.log(`${client.user.username} ready!`);

    setInterval(() => {
        client.user.setActivity(`${PREFIX}help | ${PREFIX}play  ${client.guilds.cache.size} servers `, { type: "LISTENING" });
    }, 15000);

})

The 15000 is the ms (milisecond) that you want your bot to update the status. (1000ms is equal to 1 Second.)

Due to the Discord API rules, to prevent spam, you can only update your bot status minimal every 15 seconds

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