summaryrefslogtreecommitdiff
path: root/src/bot/commands/util/prefix.ts
blob: 5ff3f0cdc383218e691d3b121b51c8e774a85e29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* import { Command, Argument } from 'discord-akairo';
import { Message } from 'discord.js';

export default class PrefixCommand extends Command {
	public constructor() {
		super('prefix', {
			category: 'Utilities',
			channel: 'guild',
			aliases: ['prefix'],
			args: [
				{
					id: 'prefix',
					type: Argument.validate('string', (_, p) => !/\s/.test(p) && p.length <= 10),
					prompt: {
						start: 'What do you want to set the prefix to?',
						retry: "C'mon. I need a prefix without spaces and less than 10 characters",
						optional: true,
					},
				},
			],
			userPermissions: ['MANAGE_GUILD'],
			description: {
				content: "Changes this server's prefix.",
				usage: '[prefix]',
				examples: ['', '?', '>'],
			},
		});
	}

	public async exec(msg: Message, { prefix }: { prefix: string }): Promise<Message | Message[] | void> {
		if (!prefix) {
			const prefix = this.client.settings.cache.guilds.get(this.client.user!.id)!.prefix;
			return msg.util!.reply(`the current prefix is \`${prefix}\`.`);
		}

		await this.client.settings.set('guild', { id: msg.guild!.id }, { prefix });
		return msg.util!.reply(`successfully set the prefix to \`${prefix}\`.`);
	}
} */