fix(bots/discord): correct timer active condition for sticky messages

This commit is contained in:
Palm
2024-08-15 22:33:12 +07:00
committed by GitHub
parent 845dd5d914
commit 96065ff175

View File

@@ -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`)