Reputation: 19
for my discord.js bot i was trying to make it have a changing status message yet i cant get timers to work, so for now heres my basic code for the status, (this code makes the bots status say "Watching: You")
client.on('ready', () =>{
console.log(`Logged in`);
client.user.setPresence({
status: "online",
game: {
name: "You",
type: "WATCHING"
}
});
});
Upvotes: 1
Views: 333
Reputation: 331
let statuses = [
{game: {name: `1`}, type: "WATCHING"},
{game: {name: `2`}, type: "PLAYING"}
{game: {name: `3`}, type: "STREAMING"}
];
let i = 0;
setInterval(() => {
// Get the status
let status = statuses[i];
// If it's undefined, it means we reached the end of the array
if(!status){
// Restart at the first status
status = statuses[0];
i = 0;
}
client.user.setPresence(status);
i++;
}, 5000);
Bot changes presence every 5 seconds
Upvotes: 1