aboutsummaryrefslogtreecommitdiff
path: root/src/commands/server-config
diff options
context:
space:
mode:
authorTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-28 21:54:50 -0600
committerTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-28 21:54:50 -0600
commit2456dab3db0d8eaae515606b83a6c0c317d009b0 (patch)
treec20448112d43c1b4ffae1395584d9b202aeee3ed /src/commands/server-config
parent1e9e334097702c68d871365fc016aa096d03c491 (diff)
parent5b5f0bf5667b922037508dfa88e40a1f8a2671ec (diff)
downloadtanzanite-2456dab3db0d8eaae515606b83a6c0c317d009b0.tar.gz
tanzanite-2456dab3db0d8eaae515606b83a6c0c317d009b0.tar.bz2
tanzanite-2456dab3db0d8eaae515606b83a6c0c317d009b0.zip
fix conflicts
Diffstat (limited to 'src/commands/server-config')
-rw-r--r--src/commands/server-config/prefix.ts68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/commands/server-config/prefix.ts b/src/commands/server-config/prefix.ts
new file mode 100644
index 0000000..c60f8fb
--- /dev/null
+++ b/src/commands/server-config/prefix.ts
@@ -0,0 +1,68 @@
+import { ApplicationCommandOptionType } from 'discord-api-types';
+import { CommandInteraction, Message, Guild as DiscordGuild } from 'discord.js';
+import { BushCommand } from '../../lib/extensions/BushCommand';
+import { SlashCommandOption } from '../../lib/extensions/Util';
+import { Guild } from '../../lib/models';
+
+export default class PrefixCommand extends BushCommand {
+ constructor() {
+ super('prefix', {
+ aliases: ['prefix'],
+ category: 'server 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: CommandInteraction, { 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}\``);
+ }
+ }
+}