From f70a7b3e6d324966e2cbed9ca1a29df4b090b3ec Mon Sep 17 00:00:00 2001 From: Dominik K Date: Sun, 5 Nov 2023 19:12:21 +0100 Subject: [PATCH] fix: dynamic status --- src/events/ready.ts | 18 ------------------ src/events/shardReady.ts | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/events/ready.ts b/src/events/ready.ts index f952f980..edc3b3bc 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -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 }, }; diff --git a/src/events/shardReady.ts b/src/events/shardReady.ts index 8e8d77c8..b933a0b1 100644 --- a/src/events/shardReady.ts +++ b/src/events/shardReady.ts @@ -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); }, };