I’m trying to set up my Discord bot so it switches between different status messages automatically. I want it to alternate every 10 seconds between showing the server count and user count. Right now my bot only displays one static status message when it starts up. I need help creating a timer that cycles through multiple activities. Here’s what I have so far:
Create a function outside the ready event to handle rotation. Store your status messages in an array and use modulo to cycle through them cleanly. This approach works great:
Modulo prevents index overflow and keeps rotation smooth. One thing - guild and user counts won’t auto-update in the status text unless you refresh them inside the function.
try putting your setPresence in a setInterval running every 10 sec. make an array of status msgs and cycle through them using a counter. make sure to reset the counter at the end, otherwise it’ll mess up.
Had the exact same problem with my first Discord bot. The issue is that guild and user counts get cached at startup, so rotation won’t show current numbers. I fixed it by putting the count calculations inside the rotation function instead of storing them statically. Try this in your interval function: bot.user.setPresence({ activities: [{ name: ${bot.guilds.cache.size} servers | !help, type: 'WATCHING' }] }); It recalculates the server count each update. Also throw some error handling around setPresence - it’ll fail if the bot loses connection temporarily. Found that out when my bot kept crashing during network issues.