avatar.ts

1import {
2	ChatInputCommandInteraction,
3	EmbedBuilder,
4	SlashCommandBuilder,
5} from 'discord.js'
6import { Command } from '@/types/bot'
7
8export default {
9	data: new SlashCommandBuilder()
10		.setName('avatar')
11		.setDescription("Get user's avatar")
12		.addUserOption((option) =>
13			option
14				.setName('user')
15				.setDescription('The user to get avatar from')
16				.setRequired(false),
17		),
18
19	async execute(interaction: ChatInputCommandInteraction) {
20		const user = interaction.options.getUser('user') ?? interaction.user
21
22		const embed = new EmbedBuilder()
23			.setColor('#0099ff')
24			.setTitle(`${user.username}'s Avatar`)
25			.setImage(user.displayAvatarURL({ size: 1024 }))
26			.setTimestamp()
27
28		await interaction.reply({ embeds: [embed] })
29	},
30} as Command
31