From 59dd80352953dac512ba3f38430f80a3904f14da Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Wed, 25 Sep 2024 06:41:17 +0700 Subject: [PATCH] chore(bots/discord): temporarily fix timer statuses being both active --- .../discord/messageCreate/stickyMessageReset.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts b/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts index 59cdcd6..d674f00 100644 --- a/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts +++ b/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts @@ -7,6 +7,18 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => { const store = discord.stickyMessages[msg.guildId]?.[msg.channelId] if (!store) return + // TODO: Fix this by fixing the logic below + if (store.timerActive && store.forceTimerActive) { + logger.error( + `Both timers are active in sticky message store: ${msg.guildId}.${msg.channelId}, this should not happen!`, + ) + logger.info('Clearing the timer and the restarting the force timer...') + clearTimeout(store.timer) + store.timerActive = false + // If the force timer is active, it implies the force timer exists + store.forceTimer!.refresh() + } + const timerPreviouslyActive = store.timerActive // If there isn't a timer, start it up store.timerActive = true