utility.avatar: fetch member if possible

This commit is contained in:
Cynthia Foxwell 2021-08-29 20:12:56 -06:00
parent 94d3f4b3e6
commit 7e6b71c802

View file

@ -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,