From 6ba346df24ebac26ec8386d77c72f6bac6cde817 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 22 Dec 2019 22:05:34 +0100 Subject: [PATCH] Show avatar in embed and with multiple format --- commands/utility/avatar.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/commands/utility/avatar.js b/commands/utility/avatar.js index ebcadebc..153039b4 100644 --- a/commands/utility/avatar.js +++ b/commands/utility/avatar.js @@ -21,10 +21,36 @@ class AvatarCommand extends Command { } async exec(message, args) { - if (!args.user) - return message.channel.send('Your avatar:', {files: [message.author.displayAvatarURL() + '?size=2048']}); - else - return message.channel.send(`${args.user.username}'s avatar:`, {files: [args.user.displayAvatarURL() + '?size=2048']}); + const avatarEmbed = this.client.util.embed() + .setColor(message.member.displayHexColor) + .setTitle('Avatar'); + + + if (!args.user) { + let format = message.author.displayAvatarURL().substr(message.author.displayAvatarURL().length - 3); + if (format == 'gif') { + avatarEmbed.setAuthor(message.author.username); + avatarEmbed.setDescription(`[gif](${message.author.displayAvatarURL({ format: 'gif', size: 2048 })})`); + avatarEmbed.setImage(message.author.displayAvatarURL({ format: 'gif', size: 2048 })); + } else { + avatarEmbed.setAuthor(message.author.username); + avatarEmbed.setDescription(`[png](${message.author.displayAvatarURL({ format: 'png', size: 2048 })}) | [jpeg](${message.author.displayAvatarURL({ format: 'jpg', size: 2048 })}) | [webp](${message.author.displayAvatarURL({ format: 'webp', size: 2048 })})`); + avatarEmbed.setImage(message.author.displayAvatarURL({ format: 'png', size: 2048 })); + } + return message.channel.send({embed: avatarEmbed}); + } else { + let format = args.user.displayAvatarURL().substr(args.user.displayAvatarURL().length - 3); + if (format == 'gif') { + avatarEmbed.setAuthor(args.user.username); + avatarEmbed.setDescription(`[gif](${args.user.displayAvatarURL({ format: 'gif', size: 2048 })})`); + avatarEmbed.setImage(args.user.displayAvatarURL({ format: 'gif', size: 2048 })); + } else { + avatarEmbed.setAuthor(args.user.username); + avatarEmbed.setDescription(`[png](${args.user.displayAvatarURL({ format: 'png', size: 2048 })}) | [jpeg](${args.user.displayAvatarURL({ format: 'jpg', size: 2048 })}) | [webp](${args.user.displayAvatarURL({ format: 'webp', size: 2048 })})`); + avatarEmbed.setImage(args.user.displayAvatarURL({ format: 'png', size: 2048 })); + } + return message.channel.send({embed: avatarEmbed}); + } } }