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

export default class DMCommand extends BotCommand {
	public constructor() {
		super('dm', {
			aliases: ['dm'],
			category: 'dev',
			description: 'Send a direct message to a specified user from the bot.',
			usage: ['dm <user> <content>'],
			examples: ['dm IRONM00N hi'],
			args: [
				{
					id: 'user',
					type: 'user',
					description: 'The user to send the dm to.',
					prompt: 'Who would you like to dm?',
					retry: '{error} Pick a valid user to send a dm to.',
					slashType: ApplicationCommandOptionType.String
				},
				{
					id: 'content',
					type: 'string',
					match: 'rest',
					description: 'The content to send to the user.',
					prompt: 'What would you like to send to the user?',
					retry: '{error} Pick something to send the user.',
					slashType: ApplicationCommandOptionType.String
				}
			],
			slash: false,
			ownerOnly: true,
			hidden: true,
			skipSendCheck: true,
			clientPermissions: [],
			userPermissions: []
		});
	}

	public override async exec(
		message: CommandMessage | SlashMessage,
		args: { user: ArgType<'user'>; content: ArgType<'string'> }
	) {
		try {
			await this.client.users.send(args.user.id, args.content);
		} catch (e) {
			return message.util.reply(`${emojis.error} There was an error sending ${format.input(args.user.tag)} a dm.`);
		}
		return message.util.reply(`${emojis.success} Successfully sent ${format.input(args.user.tag)} a dm.`);
	}
}