From 4e2ff7438a969c8773419cfef85957f1a4a15333 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sun, 3 Apr 2022 10:37:26 -0600 Subject: [PATCH] utility.avatar: attempt multi-image embed trick --- src/modules/utility.js | 60 ++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/src/modules/utility.js b/src/modules/utility.js index 6223eed..f855400 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -109,29 +109,45 @@ avatar.callback = async function (msg, line) { member = fetched[0]; } } - const avatar = member.avatar || member.user.avatar; - const url = - guild && member.avatar - ? `https://cdn.discordapp.com/guilds/${guild.id}/users/${ - member.id - }/avatars/${member.avatar}.${ - member.avatar.startsWith("a_") - ? "gif?size=1024&_=.gif" - : "png?size=1024" - }` - : `${AVATAR_BASE}${member.id}/${avatar}.${ - avatar.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024" - }`; + + const baseEmbed = { + title: `Avatar for \`${member.username}#${member.discriminator}\``, + }; + + const normalAvatar = member.user.avatar; + const guildAvatar = member.avatar; + + const normalUrl = + AVATAR_BASE + + member.id + + "/" + + normalAvatar + + "." + + normalAvatar.startsWith("a_") + ? "gif?size=1024&_=.gif" + : "png?size=1024"; + const guildUrl = + "https://cdn.discordapp.com/guilds/" + + guild.id + + "/users/" + + member.id + + "/avatars/" + + guildAvatar + + "." + + guildAvatar.startsWith("a_") + ? "gif?size=1024&_=.gif" + : "png?size=1024"; + + baseEmbed.description = + `[Normal avatar](${normalUrl})` + + (guild && guildAvatar ? `\n[Guild avatar](${guildUrl})` : ""); + + const guildEmbed = baseEmbed; + baseEmbed.image = {url: normalUrl}; + guildEmbed.image = {url: guildUrl}; + return { - embeds: [ - { - title: `Avatar for \`${member.username}#${member.discriminator}\``, - url, - image: { - url, - }, - }, - ], + embeds: [baseEmbed, guildEmbed], }; } } else {