Skip to content

Commit

Permalink
fix: dynamic status
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik K committed Nov 5, 2023
1 parent ebad543 commit f70a7b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/events/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ const event: Event = {
}
}, 2500);
}

const setStatus = () => {
if (!client.user) return;
const random = ["Would You Rather", "Truth or Dare", "What Would You Do", "Higher or Lower", "Never Have I Ever" ];
client.user.setPresence({
activities: [
{
name: `${
random[Math.floor(Math.random() * random.length)] || "Would You?"
}`,
},
],
status: "dnd",
});
};

setTimeout(() => setStatus(), 35 * 1000);
setInterval(() => setStatus(), 60 * 60 * 1000); // Do this not so often because everytime you set the presence the bot won't receive any events for some seconds
},
};

Expand Down
21 changes: 21 additions & 0 deletions src/events/shardReady.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ const event: Event = {
"Shard is now ready #" + id,
)}`,
);
const random = ["Would You Rather", "Truth or Dare", "What Would You Do", "Higher or Lower", "Never Have I Ever" ];
const randomStatus = random[Math.floor(Math.random() * random.length)];

const setStatus = () => {
if (!client.user) return;

client.user.setPresence({
activities: [
{
name: `${
randomStatus || "Would You?"
}`,
},
],
status: "dnd",
shardId: id,
});
};

setTimeout(() => setStatus(), 35 * 1000);
setInterval(() => setStatus(), 60 * 60 * 1000);
},
};

Expand Down

0 comments on commit f70a7b3

Please # to comment.