From 60bf68464fbb669c2eebd5e1c6fd00cc384f61a6 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Sun, 6 Feb 2022 18:48:36 -0700 Subject: [PATCH] -both flag for n?avatar --- commands/misc/avatar.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/commands/misc/avatar.js b/commands/misc/avatar.js index b5b7e83..c8abd6d 100644 --- a/commands/misc/avatar.js +++ b/commands/misc/avatar.js @@ -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.");} } }; \ No newline at end of file