mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 21:56:17 +00:00
Compare commits
2 Commits
@revanced/
...
@revanced/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33ba5b1f61 | ||
|
|
247a00f57f |
@@ -1,3 +1,10 @@
|
||||
# @revanced/discord-bot [1.1.0](https://github.com/revanced/revanced-bots/compare/@revanced/discord-bot@1.0.4...@revanced/discord-bot@1.1.0) (2025-04-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **bots/discord:** delete and send sticky msg concurrently, add more logging ([247a00f](https://github.com/revanced/revanced-bots/commit/247a00f57fc2a45fe828cc41e6f0e38e67e83a20))
|
||||
|
||||
## @revanced/discord-bot [1.0.4](https://github.com/revanced/revanced-bots/compare/@revanced/discord-bot@1.0.3...@revanced/discord-bot@1.0.4) (2025-04-14)
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@revanced/discord-bot",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"version": "1.0.4",
|
||||
"version": "1.1.0",
|
||||
"description": "🤖 Discord bot assisting ReVanced",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -16,47 +16,53 @@ export default withContext(on, 'ready', async ({ config, discord, logger }, clie
|
||||
`Channel ${channelId} in guild ${guildId} is not a text channel, sticky messages will not be sent`,
|
||||
)
|
||||
|
||||
const send = async () => {
|
||||
const store = discord.stickyMessages[guildId]![channelId]
|
||||
if (!store) return
|
||||
|
||||
try {
|
||||
const oldMsg = store.currentMessage
|
||||
|
||||
store.currentMessage = await channel.send({
|
||||
...message,
|
||||
embeds: message.embeds?.map(it => applyCommonEmbedStyles(it, true, true, true)),
|
||||
})
|
||||
|
||||
await oldMsg?.delete()
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
`Error while sending sticky message to channel ${channelId} in guild ${guildId}:`,
|
||||
e,
|
||||
)
|
||||
} finally {
|
||||
// Clear any remaining timers
|
||||
clearTimeout(store.timer)
|
||||
clearTimeout(store.forceTimer)
|
||||
store.forceTimerActive = store.timerActive = false
|
||||
|
||||
logger.debug(`Sent sticky message to channel ${channelId} in guild ${guildId}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the store
|
||||
discord.stickyMessages[guildId]![channelId] = {
|
||||
// biome-ignore lint/suspicious/noAssignInExpressions: don't care
|
||||
const store = (discord.stickyMessages[guildId]![channelId] = {
|
||||
forceTimerActive: false,
|
||||
timerActive: false,
|
||||
forceTimerMs: forceSendTimeout,
|
||||
timerMs: timeout,
|
||||
send,
|
||||
async send() {
|
||||
try {
|
||||
await Promise.all([
|
||||
channel
|
||||
.send({
|
||||
...message,
|
||||
embeds: message.embeds?.map(it => applyCommonEmbedStyles(it, true, true, true)),
|
||||
})
|
||||
.then(msg => {
|
||||
this.currentMessage = msg
|
||||
logger.debug(`Sent sticky message to channel ${channelId} in guild ${guildId}`)
|
||||
}),
|
||||
this.currentMessage
|
||||
?.delete()
|
||||
?.then(() =>
|
||||
logger.debug(
|
||||
`Deleted old sticky message from channel ${channelId} in guild ${guildId}`,
|
||||
),
|
||||
),
|
||||
])
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
`Error while managing sticky message of channel ${channelId} in guild ${guildId}:`,
|
||||
e,
|
||||
)
|
||||
} finally {
|
||||
// Clear any remaining timers
|
||||
clearTimeout(this.timer)
|
||||
clearTimeout(this.forceTimer)
|
||||
this.forceTimerActive = this.timerActive = false
|
||||
|
||||
logger.debug(`Cleared sticky message timer for channel ${channelId} in guild ${guildId}`)
|
||||
}
|
||||
},
|
||||
// If the store exists before the configuration refresh, take its current message
|
||||
currentMessage: oldStore?.[channelId]?.currentMessage,
|
||||
}
|
||||
})
|
||||
|
||||
// Send a new sticky message immediately, as well as deleting the old/outdated message, if it exists
|
||||
await send()
|
||||
await store.send()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user