aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev/say.ts
blob: c7b3c40f73aedd772885b8011682bc44d8d3ae7b (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
import { AllowedMentions, BushCommand, emojis, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
import { ApplicationCommandOptionType } from 'discord.js';

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

	public override async exec(message: CommandMessage | SlashMessage, args: { content: ArgType<'string'> }) {
		if (!message.author.isOwner()) return await message.util.reply(`${emojis.error} Only my developers can run this command.`);

		await message.delete().catch(() => null);
		await message.util.send({ content: args.content, allowedMentions: AllowedMentions.none() }).catch(() => null);
	}

	public override async execSlash(message: SlashMessage, args: { content: string }) {
		if (!this.client.config.owners.includes(message.author.id)) {
			return await message.interaction.reply({
				content: `${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: args.content, allowedMentions: AllowedMentions.none() }).catch(() => null);
	}
}