From 96065ff17584ff99a56ca5008327863ca5a7852b Mon Sep 17 00:00:00 2001 From: Palm Date: Thu, 15 Aug 2024 22:33:12 +0700 Subject: [PATCH] fix(bots/discord): correct timer active condition for sticky messages --- .../src/events/discord/messageCreate/stickyMessageReset.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts b/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts index e0104ac..2b18fd9 100644 --- a/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts +++ b/bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts @@ -7,12 +7,13 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => { const store = discord.stickyMessages[msg.guildId]?.[msg.channelId] if (!store) return + const timerPreviouslyActive = store.timerActive // If there isn't a timer, start it up store.timerActive = true if (!store.timer) store.timer = setTimeout(store.send, store.timerMs) as NodeJS.Timeout else { // If there is a timer, but it isn't active, restart it - if (!store.timerActive) store.timer.refresh() + if (!timerPreviouslyActive) store.timer.refresh() // If there is a timer and it is active, but the force timer isn't active... else if (!store.forceTimerActive && store.forceTimerMs) { logger.debug(`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`)