From 9cf3a5a23b3aac6976a4dde3f07371b0916048f6 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Mon, 21 Apr 2025 18:02:39 -0600 Subject: [PATCH] guildinfo: actually fix local resolving and more invite resolving --- src/modules/utility/guildinfo.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/modules/utility/guildinfo.js b/src/modules/utility/guildinfo.js index e1b2516..fcb8b7a 100644 --- a/src/modules/utility/guildinfo.js +++ b/src/modules/utility/guildinfo.js @@ -74,7 +74,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) { let clan = await hf.bot.requestHandler.request("GET", APIEndpoints.CLAN(id), true).catch(() => {}); if (!clan) { - if (_guild?.profile) { + if (_guild?.data?.profile) { clan = _guild?.profile; } else { const verif = await hf.bot.requestHandler @@ -82,11 +82,21 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) { .catch(() => {}); if (verif?.profile) { clan = verif.profile; - } else if (_guild?.vanityURL) { - const invite = await hf.bot.requestHandler - .request("GET", `${APIEndpoints.INVITE(_guild.vanityURL)}?with_counts=true&with_expiration=true`) - .catch(() => {}); - if (invite?.profile) clan = invite.profile; + } else { + const code = + _guild?.data?.vanityURL ?? + _guild?.data?.store_page?.guild?.invite?.code ?? + _guild?.data?.store_page?.role_subscription?.purchase_page_invite?.code ?? + _guild?.data?.instant_invite?.replace( + /(https?:\/\/)?(canary\.|ptb\.)?discord(\.gg|(app)?.com\/invite)\//, + "" + ); + if (code) { + const invite = await hf.bot.requestHandler + .request("GET", `${APIEndpoints.INVITE(code)}?with_counts=true&with_expiration=true`) + .catch(() => {}); + if (invite?.profile) clan = invite.profile; + } } } }