diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-19 16:43:37 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-06-19 16:43:37 -0400 |
commit | ea64ebfff9aae32deb036643422d3427959dcd24 (patch) | |
tree | 5ab83558642bad282515837424637070f547a05e /src/commands/config | |
parent | d055e0dbb86ef7fd4ee96a1531b51181e825fb4b (diff) | |
download | tanzanite-ea64ebfff9aae32deb036643422d3427959dcd24.tar.gz tanzanite-ea64ebfff9aae32deb036643422d3427959dcd24.tar.bz2 tanzanite-ea64ebfff9aae32deb036643422d3427959dcd24.zip |
feat(*): A bunch of stuff
- Remade logging
- updated dependencies
- started adding custom crap to the command handler
- added emojis to stuff
- can't remeber other stuff
Note: this is currently broken
BREAKING CHANGE:
Diffstat (limited to 'src/commands/config')
-rw-r--r-- | src/commands/config/prefix.ts | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts new file mode 100644 index 0000000..c20cfa5 --- /dev/null +++ b/src/commands/config/prefix.ts @@ -0,0 +1,69 @@ +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { Guild as DiscordGuild, Message } from 'discord.js'; +import { SlashCommandOption } from '../../lib/extensions/BushClientUtil'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { BushInteractionMessage } from '../../lib/extensions/BushInteractionMessage'; +import { Guild } from '../../lib/models'; + +export default class PrefixCommand extends BushCommand { + constructor() { + super('prefix', { + aliases: ['prefix'], + category: 'config', + args: [ + { + id: 'prefix' + } + ], + userPermissions: ['MANAGE_GUILD'], + description: { + content: 'Set the prefix of the current server (resets to default if prefix is not given)', + usage: 'prefix [prefix]', + examples: ['prefix', 'prefix +'] + }, + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.STRING, + name: 'prefix', + description: 'The prefix to set for this server', + required: false + } + ] + }); + } + + async changePrefix(guild: DiscordGuild, prefix?: string): Promise<void> { + let row = await Guild.findByPk(guild.id); + if (!row) { + row = Guild.build({ + id: guild.id + }); + } + if (prefix) { + row.prefix = prefix; + await row.save(); + } 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}\``); + } + } +} |