utility.lookupinvite: fix thumbnails

This commit is contained in:
Cynthia Foxwell 2023-05-29 20:07:21 -06:00
parent 8a1f5b9fdd
commit 6480550286

View file

@ -23,11 +23,24 @@ for (const emoji of EmojiData) {
// constants
const ICON_BASE = "https://cdn.discordapp.com/icons/";
const AVATAR_BASE = "https://cdn.discordapp.com/avatars/";
const SPLASH_BASE = "https://cdn.discordapp.com/splashes/";
const BANNER_BASE = "https://cdn.discordapp.com/banners/";
const EMOTE_BASE = "https://cdn.discordapp.com/emojis/";
const CDN = "https://cdn.discordapp.com/";
const ICON_BASE = CDN + "icons/";
const AVATAR_BASE = CDN + "avatars/";
const SPLASH_BASE = CDN + "splashes/";
const BANNER_BASE = CDN + "banners/";
const EMOTE_BASE = CDN + "emojis/";
const CHANNEL_ICON_BASE = CDN + "channel-icons/";
const DEFAULT_GROUP_DM_AVATARS = [
"/assets/ee9275c5a437f7dc7f9430ba95f12ebd.png",
"/assets/9baf45aac2a0ec2e2dab288333acb9d9.png",
"/assets/7ba11ffb1900fa2b088cb31324242047.png",
"/assets/f90fca70610c4898bc57b58bce92f587.png",
"/assets/e2779af34b8d9126b77420e5f09213ce.png",
"/assets/c6851bd0b03f1cca5a8c1e720ea6ea17.png",
"/assets/f7e38ac976a2a696161c923502a8345b.png",
"/assets/3cb840d03313467838d658bbec801fcd.png",
];
const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/;
@ -419,15 +432,6 @@ lookupinvite.callback = async function (msg, line) {
title: `Invite Info: \`${invite.code}\``,
description: invite.description,
fields: [],
thumbnail: {
url:
invite.guild.icon &&
`${ICON_BASE}${invite.guild.id}/${invite.guild.icon}.${
invite.guild.icon.startsWith("a_")
? "gif?size=1024&_=.gif"
: "png?size=1024"
}`,
},
};
const expires = {
@ -496,6 +500,15 @@ lookupinvite.callback = async function (msg, line) {
},
].filter((x) => !!x)
);
embed.thumbnail = {
url:
invite.guild.icon &&
`${ICON_BASE}${invite.guild.id}/${invite.guild.icon}.${
invite.guild.icon.startsWith("a_")
? "gif?size=1024&_=.gif"
: "png?size=1024"
}`,
};
} else if (invite.type == 1) {
embed.title += " (Group DM)";
embed.fields.push(
@ -506,9 +519,30 @@ lookupinvite.callback = async function (msg, line) {
},
expires
);
embed.thumbnail = {
url: invite.channel.icon
? `${CHANNEL_ICON_BASE}${invite.channel.id}/${invite.channel.icon}.${
invite.channel.icon.startsWith("a_")
? "gif?size=1024&_=.gif"
: "png?size=1024"
}`
: "https://discord.com" +
DEFAULT_GROUP_DM_AVATARS[
Number(invite.channel.id) % DEFAULT_GROUP_DM_AVATARS.length
],
};
} else if (invite.type == 2) {
embed.title += " (Friend)";
embed.fields.push(expires);
embed.thumbnail = {
url:
invite.inviter?.avatar &&
`${AVATAR_BASE}${invite.inviter.id}/${invite.inviter.avatar}.${
invite.inviter.avatar.startsWith("a_")
? "gif?size=1024&_=.gif"
: "png?size=1024"
}`,
};
}
if (invite.inviter) {