const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');

module.exports = {
	category: 'utility',
	data: new SlashCommandBuilder()
		.setName('avatar')
		.setDescription('Affiche l\'avatar d\'un utilisateur.')
		.addUserOption(option =>
			option.setName('user')
				.setDescription('L\'utilisateur dont tu veux voir l\'avatar')
				.setRequired(false)),
	async execute(interaction) {
		const target = interaction.options.getUser('user') || interaction.user;
		const { colors, emojis } = require('../../utils/constants');
		
		const embed = new EmbedBuilder()
			.setAuthor({ 
				name: `${target.displayName}`, 
				iconURL: target.displayAvatarURL({ dynamic: true }) 
			})
			.setTitle(`${emojis.avatar} Avatar`)
			.setColor(colors.utility)
			.setImage(target.displayAvatarURL({ dynamic: true, size: 4096 }))
			.setDescription(`[Télécharger l'avatar](${target.displayAvatarURL({ dynamic: true, size: 4096 })})`)
			.setFooter({ text: `Demandé par ${interaction.user.displayName} • ${interaction.guild.name}`, iconURL: interaction.user.displayAvatarURL() })
			.setTimestamp();

		await interaction.reply({ embeds: [embed] });
	},
};

