From 6875b32fd0c6ce3034da9dc6c704d425afb26f2e Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Fri, 2 Aug 2024 18:53:43 +0700 Subject: [PATCH] feat(bots/discord/commands): add `reload` command --- bots/discord/.gitignore | 3 --- bots/discord/src/commands/admin/reload.ts | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 bots/discord/src/commands/admin/reload.ts diff --git a/bots/discord/.gitignore b/bots/discord/.gitignore index f742463..130f357 100644 --- a/bots/discord/.gitignore +++ b/bots/discord/.gitignore @@ -174,9 +174,6 @@ dist # Finder (MacOS) folder config .DS_Store -# Config -config.ts - # DB *.db *.sqlite diff --git a/bots/discord/src/commands/admin/reload.ts b/bots/discord/src/commands/admin/reload.ts new file mode 100644 index 0000000..1a5c920 --- /dev/null +++ b/bots/discord/src/commands/admin/reload.ts @@ -0,0 +1,17 @@ +import { AdminCommand } from '$/classes/Command' +import { join, dirname } from 'path' + +import type { Config } from 'config.schema' + +export default new AdminCommand({ + name: 'reload', + description: 'Reload configuration', + async execute(context, trigger) { + context.config = ((await import(join(dirname(Bun.main), '..', 'config.js'))) as { default: Config }).default + + await trigger.reply({ + content: 'Reloaded configuration', + ephemeral: true, + }) + }, +})