aboutsummaryrefslogtreecommitdiff
path: root/src/commands/config
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-21 15:33:36 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-21 15:33:36 -0400
commit6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b (patch)
tree6b0490f7f17d5d663f0f764589328e8acb79dd22 /src/commands/config
parent5c3da90f441c321f55ae735d6002f4da91f2481e (diff)
downloadtanzanite-6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b.tar.gz
tanzanite-6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b.tar.bz2
tanzanite-6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b.zip
fix(db): made it work now
Diffstat (limited to 'src/commands/config')
-rw-r--r--src/commands/config/prefix.ts41
1 files changed, 10 insertions, 31 deletions
diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts
index 3bb717b..1326426 100644
--- a/src/commands/config/prefix.ts
+++ b/src/commands/config/prefix.ts
@@ -1,7 +1,6 @@
-import { Guild as DiscordGuild, Message } from 'discord.js';
-import { SlashCommandOption } from '../../lib/extensions/BushClientUtil';
+import { Message } from 'discord.js';
import { BushCommand } from '../../lib/extensions/BushCommand';
-import { BushInteractionMessage } from '../../lib/extensions/BushInteractionMessage';
+import { BushSlashMessage } from '../../lib/extensions/BushInteractionMessage';
import { Guild } from '../../lib/models';
export default class PrefixCommand extends BushCommand {
@@ -11,7 +10,8 @@ export default class PrefixCommand extends BushCommand {
category: 'config',
args: [
{
- id: 'prefix'
+ id: 'prefix',
+ type: 'string'
}
],
userPermissions: ['MANAGE_GUILD'],
@@ -32,39 +32,18 @@ export default class PrefixCommand extends BushCommand {
});
}
- async changePrefix(guild: DiscordGuild, prefix?: string): Promise<void> {
- let row = await Guild.findByPk(guild.id);
+ async exec(message: Message | BushSlashMessage, { prefix }: { prefix?: string }): Promise<void> {
+ let row = await Guild.findByPk(message.guild.id);
if (!row) {
row = Guild.build({
- id: guild.id
+ id: message.guild.id
});
}
- // this.client.console.debug(row);
+ await row.update({ prefix: prefix || this.client.config.prefix });
if (prefix) {
- row.prefix = prefix;
- await row.save();
+ await message.util.send(`${this.client.util.emojis.success} changed prefix from \`${prefix}\``);
} else {
- 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}\``);
- }
- }
-
- async execSlash(message: BushInteractionMessage, { prefix }: { prefix?: SlashCommandOption<string> }): Promise<void> {
- await this.changePrefix(message.guild, prefix?.value);
- if (prefix) {
- await message.reply(`Sucessfully set prefix to \`${prefix.value}\``);
- } else {
- await message.reply(`Sucessfully reset prefix to \`${this.client.config.prefix}\``);
+ await message.util.send(`${this.client.util.emojis.success} reset prefix to \`${this.client.config.prefix}\``);
}
}
}