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

52 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-03-03 06:02:08 +00:00
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
2021-03-06 14:15:07 +00:00
let member = message.member;
2021-03-03 06:02:08 +00:00
if (args[0]) {
2021-03-06 14:15:07 +00:00
if (message.mentions.length > 0) {
2021-07-15 02:53:57 +00:00
member = await client.functions.getMember(message.guild, message.mentions[0].id);
2021-03-06 14:15:07 +00:00
} else {
2021-07-15 02:53:57 +00:00
member = await client.functions.validateUserID(message.guild, args[0]);
2021-03-03 06:02:08 +00:00
2021-03-06 14:15:07 +00:00
if (!member) {
2021-07-15 02:53:57 +00:00
member = await message.guild.searchMembers(args.join(' '), 2);
2021-03-06 14:15:07 +00:00
if (member.length === 0) return message.channel.send(
2021-07-15 02:26:42 +00:00
`${client.config.emojis.userError} No users found. Check for mispellings, or ping the user instead.`
2021-03-06 14:15:07 +00:00
);
if (member.length > 1) return message.channel.send(
2021-07-15 02:26:42 +00:00
`${client.config.emojis.userError} Found more than one user, try refining your search or pinging the user instead.`
2021-03-06 14:15:07 +00:00
);
member = member[0];
}
2021-03-03 06:02:08 +00:00
}
}
const embed = new client.RichEmbed()
2021-03-06 14:15:07 +00:00
.setTitle(member.user.username + '#' + member.user.discriminator)
2021-07-15 02:53:57 +00:00
.setColour(client.functions.displayHexColour(message.guild, member))
2021-03-06 14:15:07 +00:00
.setImage(member.user.avatarURL);
2021-03-03 06:02:08 +00:00
message.channel.send({ embed: embed });
2021-03-03 06:02:08 +00:00
}
};