utility.banner: guild banners exposed finally

This commit is contained in:
Cynthia Foxwell 2024-07-11 23:41:49 -06:00
parent 39bd3f0a93
commit ce884db8bf

View file

@ -1010,21 +1010,50 @@ banner.callback = async function (msg, line, [user], {server, guild}) {
true
);
if (!userObj.banner) return "This user does not have a banner.";
let memberObj;
if (msg.guildID) {
memberObj = await hf.bot.requestHandler.request(
"GET",
`/guilds/${msg.guildID}/members/${id}`,
true
);
}
const url = `${BANNER_BASE}${userObj.id}/${userObj.banner}.${
userObj.banner.startsWith("a_") ? "gif?size=4096&_=.gif" : "png?size=4096"
}`;
if (!userObj.banner && !memberObj?.banner)
return "This user does not have a banner.";
const url =
userObj.banner &&
`${BANNER_BASE}${userObj.id}/${userObj.banner}.${
userObj.banner.startsWith("a_") ? "gif?size=4096&_=.gif" : "png?size=4096"
}`;
const guildUrl =
memberObj?.banner &&
`${CDN}guilds/${msg.guildID}/users/${userObj.id}/banners/${
memberObj.banner
}.${
memberObj.banner.startsWith("a_")
? "gif?size=4096&_=.gif"
: "png?size=4096"
}`;
return {
embeds: [
{
url && {
title: `Banner for \`${formatUsername(userObj)}\``,
url,
image: {
url,
},
},
],
guildUrl && {
title: `Server banner for \`${formatUsername(userObj)}\``,
url: guildUrl,
image: {
url: guildUrl,
},
},
].filter((x) => !!x),
};
};
hf.registerCommand(banner);