utility.avatar: fixes

This commit is contained in:
Cynthia Foxwell 2022-04-03 10:40:19 -06:00
parent 4e2ff7438a
commit 2dbe433b1d

View file

@ -123,9 +123,9 @@ avatar.callback = async function (msg, line) {
"/" +
normalAvatar +
"." +
normalAvatar.startsWith("a_")
(normalAvatar.startsWith("a_")
? "gif?size=1024&_=.gif"
: "png?size=1024";
: "png?size=1024");
const guildUrl =
"https://cdn.discordapp.com/guilds/" +
guild.id +
@ -134,9 +134,9 @@ avatar.callback = async function (msg, line) {
"/avatars/" +
guildAvatar +
"." +
guildAvatar.startsWith("a_")
(guildAvatar.startsWith("a_")
? "gif?size=1024&_=.gif"
: "png?size=1024";
: "png?size=1024");
baseEmbed.description =
`[Normal avatar](${normalUrl})` +
@ -152,28 +152,43 @@ avatar.callback = async function (msg, line) {
}
} else {
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
const avatar = msg.member.avatar || msg.author.avatar;
const url = msg.member.avatar
? `https://cdn.discordapp.com/guilds/${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: [
{
const baseEmbed = {
title: `Avatar for \`${msg.author.username}#${msg.author.discriminator}\``,
url,
image: {
url,
},
},
],
};
const normalAvatar = msg.author.avatar;
const guildAvatar = msg.member?.avatar;
const normalUrl =
AVATAR_BASE +
msg.author.id +
"/" +
normalAvatar +
"." +
(normalAvatar.startsWith("a_")
? "gif?size=1024&_=.gif"
: "png?size=1024");
const guildUrl =
"https://cdn.discordapp.com/guilds/" +
guild.id +
"/users/" +
msg.author.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: [baseEmbed, guildEmbed],
};
}
};