diff --git a/src/modules/utility.js b/src/modules/utility.js index e39e129..d5ffbd3 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -100,14 +100,25 @@ avatar.callback = async function (msg, line) { ) { return user; } else { - const avatar = user.avatar || user.user.avatar; - const url = `${AVATAR_BASE}${user.id}/${avatar}.${ + let member = user; + if (msg.channel.guild) { + if (msg.channel.guild.members.has(user.id)) { + member = msg.channel.guild.members.get(user.id); + } else { + const fetched = await msg.channel.guild.fetchMembers({ + userIDs: [user.id], + }); + member = fetched[0]; + } + } + const avatar = member.avatar || member.user.avatar; + const url = `${AVATAR_BASE}${member.id}/${avatar}.${ avatar.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024" }`; return { embeds: [ { - title: `Avatar for \`${user.username}#${user.discriminator}\``, + title: `Avatar for \`${member.username}#${member.discriminator}\``, url, image: { url,