aboutsummaryrefslogtreecommitdiff
path: root/src/commands/config/prefix.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-27 18:08:14 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-27 18:08:14 -0400
commit747b3c8302245699294b671d19b3d31d63f80bc1 (patch)
treead3d987bb38d5bdaed67e6aca1263fb06331f746 /src/commands/config/prefix.ts
parent4176b6258e44e4a095376aaf0f4c687244243a69 (diff)
downloadtanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.tar.gz
tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.tar.bz2
tanzanite-747b3c8302245699294b671d19b3d31d63f80bc1.zip
did this a while ago so I don't remeber what I did
Diffstat (limited to 'src/commands/config/prefix.ts')
-rw-r--r--src/commands/config/prefix.ts49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts
index 5b73a1a..fc7b3bf 100644
--- a/src/commands/config/prefix.ts
+++ b/src/commands/config/prefix.ts
@@ -1,13 +1,20 @@
+import { ApplicationCommandOptionType } from 'discord-api-types';
import { BushCommand } from '../../lib/extensions/BushCommand';
-import { BushSlashMessage } from '../../lib/extensions/BushInteractionMessage';
import { BushMessage } from '../../lib/extensions/BushMessage';
-import { Guild } from '../../lib/models';
+import { BushSlashMessage } from '../../lib/extensions/BushSlashMessage';
export default class PrefixCommand extends BushCommand {
constructor() {
super('prefix', {
aliases: ['prefix'],
category: 'config',
+ description: {
+ content: 'Set or reset the prefix for the server.',
+ usage: 'prefix [prefix]',
+ examples: ['prefix', 'prefix +']
+ },
+ clientPermissions: ['SEND_MESSAGES'],
+ userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'],
args: [
{
id: 'prefix',
@@ -19,37 +26,31 @@ export default class PrefixCommand extends BushCommand {
}
}
],
- clientPermissions: ['SEND_MESSAGES'],
- userPermissions: ['SEND_MESSAGES', '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 +']
- },
+ slash: true,
slashOptions: [
{
- type: 'STRING',
+ type: ApplicationCommandOptionType.STRING,
name: 'prefix',
- description: 'The prefix to set for this server',
+ description: 'What would you like the new prefix to be?',
required: false
}
- ],
- slash: true
+ ]
});
}
- async exec(message: BushMessage | BushSlashMessage, { prefix }: { prefix?: string }): Promise<void> {
- let row = await Guild.findByPk(message.guild.id);
- if (!row) {
- row = Guild.build({
- id: message.guild.id
- });
- }
- await row.update({ prefix: prefix || this.client.config.prefix });
- if (prefix) {
- await message.util.send(`${this.client.util.emojis.success} changed prefix from \`${prefix}\` to `);
+ async exec(message: BushMessage | BushSlashMessage, args: { prefix?: string }): Promise<unknown> {
+ const oldPrefix = message.guild.getSetting('prefix');
+ await message.guild.setSetting('prefix', args.prefix ?? this.client.config.prefix);
+ if (args.prefix) {
+ return await message.util.send(
+ `${this.client.util.emojis.success} changed the server's prefix ${oldPrefix ? `from \`${oldPrefix}\`` : ''} to \`${
+ args.prefix
+ }\`.`
+ );
} else {
- await message.util.send(`${this.client.util.emojis.success} reset prefix to \`${this.client.config.prefix}\``);
+ return await message.util.send(
+ `${this.client.util.emojis.success} reset the server's prefix to \`${this.client.config.prefix}\`.`
+ );
}
}
}