avatar command

This commit is contained in:
Emily 2022-12-11 17:23:21 +11:00
parent c33e02e06d
commit c3490af9d0
2 changed files with 33 additions and 52 deletions

View file

@ -0,0 +1,33 @@
const Command = require("../../base/Command.js");
module.exports = class Avatar extends Command {
constructor (name, category) {
super (name, category)
this.name = name,
this.description = 'View a full-sized version of someone\'s avatar.',
this.options = [
{
type: 6,
name: "user",
description: "The user to get the avatar of."
},
],
this.usage = "/avatar [user]"
this.friendlyOptions = "`user` - The user to get the avatar of (optional)",
this.category = category
}
async run (client, interaction, data) { //eslint-disable-line no-unused-vars
const target = await interaction.options.getUser('user') ?? interaction.user;
const user = await client.users.fetch(target.id, {force: true})
const member = await interaction.guild.members.fetch(target.id, {force: true})
const embed = new client.EmbedBuilder()
.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}));
await interaction.reply({embeds: [embed]});
}
};

View file

@ -1,52 +0,0 @@
module.exports = class {
constructor (name, category) {
this.name = name,
this.category = category,
this.enabled = true,
this.devOnly = false,
this.aliases = ['pfp'],
this.userPerms = [],
this.botPerms = [],
this.cooldown = 2000,
this.help = {
description: 'View a full-sized version of someone\'s avatar.',
arguments: '<user>',
details: '',
examples: 'avatar\navatar @May\navatar emily'
};
}
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
let member = message.member;
if (args[0]) {
if (message.mentions.length > 0) {
member = await message.guild.members.fetch(message.mentions[0].id)
} else {
member = await client.functions.validateUserID(message.guild, args[0]);
if (!member) {
member = await message.guild.searchMembers(args.join(' '), 2);
if (member.length === 0) return message.channel.send(
`${client.config.emojis.userError} No users found. Check for mispellings, or ping the user instead.`
);
if (member.length > 1) return message.channel.send(
`${client.config.emojis.userError} Found more than one user, try refining your search or pinging the user instead.`
);
member = member[0];
}
}
}
const embed = new client.MessageEmbed()
.setTitle(member.user.username + '#' + member.user.discriminator)
.setColor(client.functions.embedColor(message.guild, member))
.setImage(member.user.avatarURL);
message.channel.send({ embeds: [embed] });
}
};