lookupinvite: nullcheck guild features

This commit is contained in:
Cynthia Foxwell 2024-07-30 20:26:33 -06:00
parent 850228e237
commit a39bffd0df

View file

@ -25,7 +25,7 @@ lookupinvite.callback = async function (msg, line) {
line = line.replace(/(https?:\/\/)?discord(\.gg|(app)?.com\/invite)\//, "");
if (decodeURI(line).indexOf("../") > -1) return "nuh uh";
if (decodeURIComponent(line).indexOf("../") > -1) return "nuh uh";
let bail = false;
let error;
@ -74,8 +74,6 @@ lookupinvite.callback = async function (msg, line) {
}
: null;
const features = formatGuildFeatures(invite.guild.features);
switch (invite.type) {
case 0: {
embed.fields.push(
@ -114,6 +112,12 @@ lookupinvite.callback = async function (msg, line) {
.join("\n")}`,
inline: false,
},
].filter((x) => !!x)
);
if (invite.guild.features) {
const features = formatGuildFeatures(invite.guild.features);
embed.fields.push(
{
name: `Features (${features.length})`,
value: features.length > 0 ? features.slice(0, Math.ceil(features.length / 2)).join("\n") : "None",
@ -125,9 +129,9 @@ lookupinvite.callback = async function (msg, line) {
value: features.slice(Math.ceil(features.length / 2), features.length).join("\n"),
inline: true,
}
: null,
].filter((x) => !!x)
: null
);
}
const guildIcon = invite.guild?.icon && CDNEndpoints.GUILD_ICON(invite.guild.id, invite.guild.icon);
const guildSplash = invite.guild?.splash && CDNEndpoints.GUILD_SPLASH(invite.guild.id, invite.guild.splash);