aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/client
diff options
context:
space:
mode:
authorTymanWasTaken <tyman@tyman.tech>2021-05-16 21:40:52 -0400
committerTymanWasTaken <tyman@tyman.tech>2021-05-16 21:40:52 -0400
commit284e1d1d693486f6c50cdb8b38f01cdf74eb63d2 (patch)
tree1c05e9bb592018f82302688180e87b4bf1305ca5 /src/listeners/client
parent372718e567e060cead16dde5d6d190666b4dd575 (diff)
downloadtanzanite-284e1d1d693486f6c50cdb8b38f01cdf74eb63d2.tar.gz
tanzanite-284e1d1d693486f6c50cdb8b38f01cdf74eb63d2.tar.bz2
tanzanite-284e1d1d693486f6c50cdb8b38f01cdf74eb63d2.zip
fix logging for slash command syncing, rename a few files
Diffstat (limited to 'src/listeners/client')
-rw-r--r--src/listeners/client/syncslashcommands.ts (renamed from src/listeners/client/CreateSlashCommands.ts)29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/listeners/client/CreateSlashCommands.ts b/src/listeners/client/syncslashcommands.ts
index c395b3a..2388104 100644
--- a/src/listeners/client/CreateSlashCommands.ts
+++ b/src/listeners/client/syncslashcommands.ts
@@ -10,39 +10,42 @@ export default class CreateSlashCommands extends BotListener {
}
async exec(): Promise<void> {
try {
- const enabled = await this.client.application.commands.fetch();
- for (const command of enabled) {
+ const registered = await this.client.application.commands.fetch();
+ for (const [, registeredCommand] of registered) {
if (
!this.client.commandHandler.modules.find(
- (cmd) => cmd.id == command[1].name
+ (cmd) => cmd.id == registeredCommand.name
)
) {
- await this.client.application.commands.delete(command[1].id);
+ await this.client.application.commands.delete(registeredCommand.id);
this.client.logger.verbose(
- `{red Deleted slash command ${command[1].name}}`
+ `{red Deleted slash command ${registeredCommand.name}}`
);
}
}
- for (const cmd of this.client.commandHandler.modules) {
- if (cmd[1].execSlash) {
- const found = enabled.find((i) => i.name == cmd[1].id);
+ for (const [, botCommand] of this.client.commandHandler.modules) {
+ if (botCommand.execSlash) {
+ const found = registered.find((i) => i.name == botCommand.id);
const slashdata = {
- name: cmd[1].id,
- description: cmd[1].description.content,
- options: cmd[1].options.slashCommandOptions
+ 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(
+ `{orange Edited slash command ${botCommand.id}}`
+ );
}
} else {
+ await this.client.application.commands.create(slashdata);
this.client.logger.verbose(
- `{red Deleted slash command ${cmd[1].id}}`
+ `{green Created slash command ${botCommand.id}}`
);
- await this.client.application.commands.create(slashdata);
}
}
}