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

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

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 Report

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