aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev/say.ts
blob: 9dc26325177dec25348a431b8007eb3f41979f72 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { AllowedMentions, BushCommand, BushMessage } from '@lib';
import { AkairoMessage } from 'discord-akairo';

export default class SayCommand extends BushCommand {
	public constructor() {
		super('say', {
			aliases: ['say'],
			category: 'dev',
			description: {
				content: 'A command make the bot say something.',
				usage: 'say <message>',
				examples: ['say hello']
			},
			args: [
				{
					id: 'say',
					type: 'string',
					match: 'rest',
					prompt: {
						start: 'What would you like the bot to say?',
						retry: '{error} Choose something valid to say.'
					}
				}
			],
			slashOptions: [
				{
					name: 'content',
					description: 'What would you like the bot to say?',
					type: 'STRING'
				}
			],
			ownerOnly: true,
			clientPermissions: ['SEND_MESSAGES'],
			slash: true
		});
	}

	public async exec(message: BushMessage, { say }: { say: string }): Promise<unknown> {
		if (!message.author.isOwner())
			return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`);

		if (message.deletable) {
			await message.delete();
		}
		await message.util.send({ content: say, allowedMentions: AllowedMentions.none() });
	}

	public async execSlash(message: AkairoMessage, { content }: { content: string }): Promise<unknown> {
		if (!this.client.config.owners.includes(message.author.id)) {
			return await message.interaction.reply({
				content: `${this.client.util.emojis.error} Only my developers can run this command.`,
				ephemeral: true
			});
		}
		await message.interaction.reply({ content: 'Attempting to send message.', ephemeral: true });
		return message.channel.send({ content, allowedMentions: AllowedMentions.none() });
	}
}