From 336a9abedda4b4bf81e9357d5bf662cc975412a5 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sun, 29 Aug 2021 20:16:44 -0600 Subject: [PATCH] utility.avatar: guild avatar support try 2 --- src/modules/utility.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/modules/utility.js b/src/modules/utility.js index d5ffbd3..f62d164 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -112,9 +112,18 @@ avatar.callback = async function (msg, line) { } } const avatar = member.avatar || member.user.avatar; - const url = `${AVATAR_BASE}${member.id}/${avatar}.${ - avatar.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024" - }`; + const url = + msg.channel.guild && member.avatar + ? `https://cdn.discordapp.com/guilds/${msg.channel.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" + }`; return { embeds: [ { @@ -129,9 +138,17 @@ avatar.callback = async function (msg, line) { } } else { const avatar = msg.member.avatar || msg.author.avatar; - const url = `${AVATAR_BASE}${msg.author.id}/${avatar}.${ - avatar.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024" - }`; + const url = msg.member.avatar + ? `https://cdn.discordapp.com/guilds/${msg.channel.guild.id}/users/${ + msg.member.id + }/avatars/${msg.member.avatar}.${ + msg.member.avatar.startsWith("a_") + ? "gif?size=1024&_=.gif" + : "png?size=1024" + }` + : `${AVATAR_BASE}${msg.author.id}/${avatar}.${ + avatar.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024" + }`; return { embeds: [ {