mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
fix(bots/discord): attempt to fix sticky messages one last time
This commit is contained in:
@@ -9,9 +9,8 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => {
|
|||||||
|
|
||||||
if (store.timerActive) {
|
if (store.timerActive) {
|
||||||
// Timer is already active, so we try to start the force timer
|
// 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
|
// Force timer isn't active, so we start it
|
||||||
if (!store.forceTimerActive) {
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
||||||
)
|
)
|
||||||
@@ -20,26 +19,15 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => {
|
|||||||
clearTimeout(store.timer)
|
clearTimeout(store.timer)
|
||||||
store.timerActive = false
|
store.timerActive = false
|
||||||
|
|
||||||
// (Re)start the force timer
|
// Start the force timer
|
||||||
store.forceTimerActive = true
|
store.forceTimerActive = true
|
||||||
if (!store.forceTimer)
|
// biome-ignore lint/suspicious/noAssignInExpressions: This works fine
|
||||||
store.forceTimer = setTimeout(
|
;(store.forceTimer ??= setTimeout(store.send, store.forceTimerMs)).refresh()
|
||||||
() =>
|
}
|
||||||
store.send(true).then(() => {
|
} else if (store.forceTimerActive) {
|
||||||
store.forceTimerActive = false
|
// Force timer is already active, so force send the message, and clear the force timer
|
||||||
}),
|
|
||||||
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)
|
store.send(true)
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
} else if (!store.forceTimerActive) {
|
|
||||||
// Both timers aren't active, so we start the timer
|
// Both timers aren't active, so we start the timer
|
||||||
store.timerActive = true
|
store.timerActive = true
|
||||||
if (!store.timer) store.timer = setTimeout(store.send, store.timerMs) as NodeJS.Timeout
|
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)
|
if (!forced)
|
||||||
logger.debug(
|
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
|
else
|
||||||
logger.debug(
|
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}`)
|
logger.debug(`Sent sticky message to channel ${channelId} in guild ${guildId}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user