mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 05:46:16 +00:00
fix(bots/discord): attempt to fix sticky messages one last time
This commit is contained in:
@@ -9,37 +9,25 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => {
|
||||
|
||||
if (store.timerActive) {
|
||||
// Timer is already active, so we try to start the force timer
|
||||
if (store.forceTimerMs) {
|
||||
if (store.forceTimerMs && !store.forceTimerActive) {
|
||||
// Force timer isn't active, so we start it
|
||||
if (!store.forceTimerActive) {
|
||||
logger.debug(
|
||||
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
||||
)
|
||||
logger.debug(
|
||||
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
||||
)
|
||||
|
||||
// Clear the timer
|
||||
clearTimeout(store.timer)
|
||||
store.timerActive = false
|
||||
// Clear the timer
|
||||
clearTimeout(store.timer)
|
||||
store.timerActive = false
|
||||
|
||||
// (Re)start the force timer
|
||||
store.forceTimerActive = true
|
||||
if (!store.forceTimer)
|
||||
store.forceTimer = setTimeout(
|
||||
() =>
|
||||
store.send(true).then(() => {
|
||||
store.forceTimerActive = false
|
||||
}),
|
||||
store.forceTimerMs,
|
||||
) as NodeJS.Timeout
|
||||
else store.forceTimer.refresh()
|
||||
} else {
|
||||
// Force timer is already active, so we clear the force timer
|
||||
store.forceTimerActive = false
|
||||
clearTimeout(store.forceTimer)
|
||||
// and force send
|
||||
store.send(true)
|
||||
}
|
||||
// Start the force timer
|
||||
store.forceTimerActive = true
|
||||
// biome-ignore lint/suspicious/noAssignInExpressions: This works fine
|
||||
;(store.forceTimer ??= setTimeout(store.send, store.forceTimerMs)).refresh()
|
||||
}
|
||||
} else if (!store.forceTimerActive) {
|
||||
} else if (store.forceTimerActive) {
|
||||
// Force timer is already active, so force send the message, and clear the force timer
|
||||
store.send(true)
|
||||
} else {
|
||||
// Both timers aren't active, so we start the timer
|
||||
store.timerActive = true
|
||||
if (!store.timer) store.timer = setTimeout(store.send, store.timerMs) as NodeJS.Timeout
|
||||
|
||||
@@ -45,11 +45,11 @@ export default withContext(on, 'ready', async ({ config, discord, logger }, clie
|
||||
|
||||
if (!forced)
|
||||
logger.debug(
|
||||
`Timeout ended for sticky message in channel ${channelId} in guild ${guildId}, channel is inactive`,
|
||||
`Timer ended for sticky message in channel ${channelId} in guild ${guildId}, channel is inactive`,
|
||||
)
|
||||
else
|
||||
logger.debug(
|
||||
`Forced send timeout for sticky message in channel ${channelId} in guild ${guildId} ended, channel is too active`,
|
||||
`Force timer for sticky message in channel ${channelId} in guild ${guildId} hasn't ended but a message was sent, channel is too active`,
|
||||
)
|
||||
|
||||
logger.debug(`Sent sticky message to channel ${channelId} in guild ${guildId}`)
|
||||
|
||||
Reference in New Issue
Block a user