mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-18 16:53:57 +00:00
fix(bots/discord): some configuration values not applying after running /reload
This commit is contained in:
@@ -7,11 +7,29 @@ export default new AdminCommand({
|
|||||||
name: 'reload',
|
name: 'reload',
|
||||||
description: 'Reload configuration',
|
description: 'Reload configuration',
|
||||||
async execute(context, trigger) {
|
async execute(context, trigger) {
|
||||||
|
const { api, logger, discord } = context
|
||||||
context.config = ((await import(join(dirname(Bun.main), '..', 'config.js'))) as { default: Config }).default
|
context.config = ((await import(join(dirname(Bun.main), '..', 'config.js'))) as { default: Config }).default
|
||||||
|
|
||||||
await trigger.reply({
|
if ('deferReply' in trigger) await trigger.deferReply({ ephemeral: true })
|
||||||
content: 'Reloaded configuration',
|
|
||||||
ephemeral: true,
|
logger.info('Reinitializing API client to reload configuration...')
|
||||||
})
|
await api.client.ws.setOptions(
|
||||||
|
{
|
||||||
|
url: context.config.api.url,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
api.intentionallyDisconnecting = true
|
||||||
|
api.client.disconnect(true)
|
||||||
|
api.disconnectCount = 0
|
||||||
|
api.intentionallyDisconnecting = false
|
||||||
|
await api.client.connect()
|
||||||
|
|
||||||
|
logger.info('Reinitializing Discord client to reload configuration...')
|
||||||
|
await discord.client.destroy()
|
||||||
|
await discord.client.login()
|
||||||
|
|
||||||
|
// @ts-expect-error: TypeScript dum
|
||||||
|
await trigger[('deferReply' in trigger ? 'editReply' : 'reply')]({ content: 'Reloaded configuration' })
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user