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