|
|
|
@ -2,6 +2,7 @@ const Discord = require('discord.js'); |
|
|
|
|
|
|
|
|
|
const {Tag} = require('../../util/tag'); |
|
|
|
|
const {TagFilter} = require('../../util/tagfilter'); |
|
|
|
|
const {Pagination} = require('../../util/pagination'); |
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
|
name: "avatar", |
|
|
|
@ -15,21 +16,36 @@ module.exports = { |
|
|
|
|
}, |
|
|
|
|
async execute(message, msg, args, cmd, prefix, mention, client) { |
|
|
|
|
let member = args.length ? (mention || client.users.cache.get(args[0]) || message.author) : message.author; |
|
|
|
|
client.users.fetch(member.id, {force: true}); |
|
|
|
|
if (message.guild) {message.guild.members.fetch(member.id, {force: true});} |
|
|
|
|
let name = message.guild ? message.guild.members.cache.get(member.id).displayName : member.username; |
|
|
|
|
let options = new TagFilter([ |
|
|
|
|
new Tag(['small', 's', 'mini', 'm'], 'small', 'toggle'), |
|
|
|
|
new Tag(['verysmall', 'vsmall', '-vs', 'xs'], 'vsmall', 'toggle'), |
|
|
|
|
new Tag(['g', 'global', 'user', 'u'], 'global', 'toggle'), |
|
|
|
|
new Tag(['b', 'both'], 'both', 'toggle') |
|
|
|
|
]).test(args.join(" ")); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
let avem = new Discord.MessageEmbed() |
|
|
|
|
.setTitle(`${name.endsWith('s') ? `${name}'` : `${name}'s`} Avatar`) |
|
|
|
|
.setImage(message.guild ? (options.global ? client.users : message.guild.members).cache.get(member.id).displayAvatarURL({size: options.vsmall ? 128 : options.small ? 256 : 2048, dynamic: true, format: "png"}) : member.displayAvatarURL({size: options.vsmall ? 128 : options.small ? 256 : 2048, dynamic: true, format: "png"})) |
|
|
|
|
.setColor('c375f0') |
|
|
|
|
.setFooter({text: "Natsuki", iconURL: client.user.displayAvatarURL()}) |
|
|
|
|
if (!options.vsmall) {avem.setTimestamp();} |
|
|
|
|
return message.channel.send({embeds: [avem]}); |
|
|
|
|
if (options.both && message.guild ? member.displayAvatarURL({size: 2048, dynamic: true, format: 'png'}) !== message.guild.members.cache.get(member.id).displayAvatarURL({size: 2048, dynamic: true, format: 'png'}) : false) { |
|
|
|
|
const pag = new Pagination(message.channel, [message.guild.members, client.users] |
|
|
|
|
.map(source => source.cache.get(member.id).displayAvatarURL({size: options.vsmall ? 128 : options.small ? 256 : 2048, dynamic: true, format: "png"})) |
|
|
|
|
.map((avatar, index) => new Discord.MessageEmbed() |
|
|
|
|
.setTitle(`${name.endsWith('s') ? `${name}'` : `${name}'s`} ${['Server', 'Global'][index]} Avatar`) |
|
|
|
|
.setImage(avatar) |
|
|
|
|
.setColor('c375f0') |
|
|
|
|
), message, client |
|
|
|
|
); |
|
|
|
|
return await pag.start({user: message.author.id, time: 60000}); |
|
|
|
|
} else { |
|
|
|
|
let avem = new Discord.MessageEmbed() |
|
|
|
|
.setTitle(`${name.endsWith('s') ? `${name}'` : `${name}'s`} Avatar`) |
|
|
|
|
.setImage(message.guild ? (options.global ? client.users : message.guild.members).cache.get(member.id).displayAvatarURL({size: options.vsmall ? 128 : options.small ? 256 : 2048, dynamic: true, format: "png"}) : member.displayAvatarURL({size: options.vsmall ? 128 : options.small ? 256 : 2048, dynamic: true, format: "png"})) |
|
|
|
|
.setColor('c375f0') |
|
|
|
|
.setFooter({text: "Natsuki", iconURL: client.user.displayAvatarURL()}) |
|
|
|
|
if (!options.vsmall) {avem.setTimestamp();} |
|
|
|
|
return message.channel.send({embeds: [avem]}); |
|
|
|
|
} |
|
|
|
|
} catch (e) {console.error(e); return message.reply("Hmm, there seems to have been an error while I tried to show you that user's avatar.");} |
|
|
|
|
} |
|
|
|
|
}; |