aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info/avatar.ts
blob: dc10f7db3a3bd4dc0e9bfa3451574ba9af0345f2 (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 { Constants } from 'discord-akairo';
import { MessageEmbed, User } from 'discord.js';
import { BushCommand, BushMessage, BushSlashMessage } from '../../lib';

export default class AvatarCommand extends BushCommand {
	constructor() {
		super('avatar', {
			aliases: ['avatar', 'av'],
			category: 'info',
			description: {
				content: "A command to get a user's avatar",
				usage: 'avatar [user]',
				examples: 'avatar'
			},
			args: [
				{
					id: 'user',
					type: Constants.ArgumentTypes.USER,
					match: Constants.ArgumentMatches.PHRASE,
					prompt: {
						start: 'Who would you like to see the avatar of?',
						retry: '{error} Choose a valid user.',
						optional: true
					}
				}
			],
			clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'],
			slash: true,
			slashOptions: [
				{
					name: 'user',
					description: 'The user you would like to find the avatar of.',
					type: 'USER',
					required: false
				}
			]
		});
	}

	async exec(message: BushMessage | BushSlashMessage, { user }: { user: User }): Promise<void> {
		user = user ?? message.author;

		const embed = new MessageEmbed()
			.setTimestamp()
			.setColor(util.colors.default)
			.setTitle(user.tag)
			.setImage(user.avatarURL({ size: 2048, format: 'png', dynamic: true }));

		await message.util.reply({ embeds: [embed] });
	}
}