aboutsummaryrefslogtreecommitdiff
path: root/src/commands/admin
diff options
context:
space:
mode:
authorTymanWasTaken <tyman@tyman.tech>2021-05-16 22:23:12 -0400
committerTymanWasTaken <tyman@tyman.tech>2021-05-16 22:23:12 -0400
commit4d63c4af57a7391dd61106b79874b8e83c14971a (patch)
tree4d9aa589b3501169d9ddfe8f0fdff50d9080b553 /src/commands/admin
parent759e93bec4e9e2eb86db7434007345c24b0a0252 (diff)
downloadtanzanite-4d63c4af57a7391dd61106b79874b8e83c14971a.tar.gz
tanzanite-4d63c4af57a7391dd61106b79874b8e83c14971a.tar.bz2
tanzanite-4d63c4af57a7391dd61106b79874b8e83c14971a.zip
change all existing slash commands to have no repeating code, add help slash command
Diffstat (limited to 'src/commands/admin')
-rw-r--r--src/commands/admin/prefix.ts25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/commands/admin/prefix.ts b/src/commands/admin/prefix.ts
index 32af649..6d0273b 100644
--- a/src/commands/admin/prefix.ts
+++ b/src/commands/admin/prefix.ts
@@ -1,5 +1,5 @@
import { ApplicationCommandOptionType } from 'discord-api-types';
-import { CommandInteraction, Message } from 'discord.js';
+import { CommandInteraction, Message, Guild as DiscordGuild } from 'discord.js';
import { BotCommand } from '../../lib/extensions/BotCommand';
import { Guild } from '../../lib/models';
@@ -29,16 +29,24 @@ export default class PrefixCommand extends BotCommand {
]
});
}
- async exec(message: Message, { prefix }: { prefix?: string }): Promise<void> {
+
+ async changePrefix(guild: DiscordGuild, prefix?: string): Promise<void> {
if (prefix) {
- const row = await Guild.findByPk(message.guild.id);
+ const row = await Guild.findByPk(guild.id);
row.prefix = prefix;
await row.save();
- await message.util.send(`Sucessfully set prefix to \`${prefix}\``);
} else {
- const row = await Guild.findByPk(message.guild.id);
+ const row = await Guild.findByPk(guild.id);
row.prefix = this.client.config.prefix;
await row.save();
+ }
+ }
+
+ async exec(message: Message, { prefix }: { prefix?: string }): Promise<void> {
+ await this.changePrefix(message.guild, prefix);
+ if (prefix) {
+ await message.util.send(`Sucessfully set prefix to \`${prefix}\``);
+ } else {
await message.util.send(
`Sucessfully reset prefix to \`${this.client.config.prefix}\``
);
@@ -50,15 +58,10 @@ export default class PrefixCommand extends BotCommand {
| string
| undefined;
+ await this.changePrefix(message.guild, prefix);
if (prefix) {
- const row = await Guild.findByPk(message.guild.id);
- row.prefix = prefix;
- await row.save();
await message.reply(`Sucessfully set prefix to \`${prefix}\``);
} else {
- const row = await Guild.findByPk(message.guild.id);
- row.prefix = this.client.config.prefix;
- await row.save();
await message.reply(
`Sucessfully reset prefix to \`${this.client.config.prefix}\``
);