aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/client
diff options
context:
space:
mode:
authorTymanWasTaken <tyman@tyman.tech>2021-05-17 14:06:24 -0400
committerTymanWasTaken <tyman@tyman.tech>2021-05-17 14:06:24 -0400
commit9aee8c80067530b178612f1261c38b83683f266d (patch)
tree2ac52f719bdd77ef0265da2de02336f0759deaba /src/listeners/client
parent4d63c4af57a7391dd61106b79874b8e83c14971a (diff)
downloadtanzanite-9aee8c80067530b178612f1261c38b83683f266d.tar.gz
tanzanite-9aee8c80067530b178612f1261c38b83683f266d.tar.bz2
tanzanite-9aee8c80067530b178612f1261c38b83683f266d.zip
probably works idk what all I did
Diffstat (limited to 'src/listeners/client')
-rw-r--r--src/listeners/client/syncslashcommands.ts50
1 files changed, 1 insertions, 49 deletions
diff --git a/src/listeners/client/syncslashcommands.ts b/src/listeners/client/syncslashcommands.ts
index eb65b97..66f530f 100644
--- a/src/listeners/client/syncslashcommands.ts
+++ b/src/listeners/client/syncslashcommands.ts
@@ -1,4 +1,3 @@
-import chalk from 'chalk';
import { BotListener } from '../../lib/extensions/BotListener';
export default class CreateSlashCommands extends BotListener {
@@ -9,53 +8,6 @@ export default class CreateSlashCommands extends BotListener {
});
}
async exec(): Promise<void> {
- try {
- const registered = await this.client.application.commands.fetch();
- for (const [, registeredCommand] of registered) {
- if (
- !this.client.commandHandler.modules.find(
- (cmd) => cmd.id == registeredCommand.name
- )
- ) {
- await this.client.application.commands.delete(registeredCommand.id);
- this.client.logger.verbose(
- chalk`{red Deleted slash command ${registeredCommand.name}}`
- );
- }
- }
-
- for (const [, botCommand] of this.client.commandHandler.modules) {
- if (botCommand.execSlash) {
- const found = registered.find((i) => i.name == botCommand.id);
-
- const slashdata = {
- name: botCommand.id,
- description: botCommand.description.content,
- options: botCommand.options.slashCommandOptions
- };
-
- if (found?.id) {
- if (slashdata.description !== found.description) {
- await this.client.application.commands.edit(found.id, slashdata);
- this.client.logger.verbose(
- chalk`{orange Edited slash command ${botCommand.id}}`
- );
- }
- } else {
- await this.client.application.commands.create(slashdata);
- this.client.logger.verbose(
- chalk`{green Created slash command ${botCommand.id}}`
- );
- }
- }
- }
-
- return this.client.logger.log(chalk.green('Slash commands registered'));
- } catch (e) {
- console.log(chalk.red(e));
- return this.client.logger.error(
- chalk`{red Slash commands not registered, see above error.}`
- );
- }
+ await this.client.util.syncSlashCommands();
}
}