woomy-v2/bot/commands/Utility/avatar.js

33 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-12-12 01:25:48 +00:00
const Command = require('../../base/Command.js');
2022-12-11 06:23:21 +00:00
module.exports = class Avatar extends Command {
constructor (name, category) {
2022-12-12 01:25:48 +00:00
super (name, category);
2022-12-11 06:23:21 +00:00
this.name = name,
this.description = 'View a full-sized version of someone\'s avatar.',
this.options = [
{
type: 6,
2022-12-12 01:25:48 +00:00
name: 'user',
description: 'The user to get the avatar of.'
2022-12-11 06:23:21 +00:00
},
],
2022-12-12 01:25:48 +00:00
this.usage = '/avatar [user]',
this.friendlyOptions = '`user` - The user to get the avatar of (optional)',
this.category = category;
2022-12-11 06:23:21 +00:00
}
async run (client, interaction, data) { //eslint-disable-line no-unused-vars
const target = await interaction.options.getUser('user') ?? interaction.user;
2022-12-12 01:25:48 +00:00
const user = await client.users.fetch(target.id, {force: true});
const member = await interaction.guild.members.fetch(target.id, {force: true});
2022-12-11 06:23:21 +00:00
const embed = new client.EmbedBuilder()
2022-12-12 01:25:48 +00:00
.setTitle(user.username + '#' + user.discriminator + '\'s avatar')
.setColor(user.hexAccentColor ?? member.displayHexColor)
.setDescription(`[Global avatar](${user.avatarURL({extension: 'png', 'size': 4096})})`)
.setImage(member.displayAvatarURL({extension: 'png', 'size': 4096}));
2022-12-11 06:23:21 +00:00
interaction.reply({embeds: [embed]});
2022-12-11 06:23:21 +00:00
}
};