guildinfo: actually fix local resolving and more invite resolving

This commit is contained in:
Cynthia Foxwell 2025-04-21 18:02:39 -06:00
parent 89480d98d7
commit 9cf3a5a23b
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -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(() => {}); let clan = await hf.bot.requestHandler.request("GET", APIEndpoints.CLAN(id), true).catch(() => {});
if (!clan) { if (!clan) {
if (_guild?.profile) { if (_guild?.data?.profile) {
clan = _guild?.profile; clan = _guild?.profile;
} else { } else {
const verif = await hf.bot.requestHandler const verif = await hf.bot.requestHandler
@ -82,11 +82,21 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
.catch(() => {}); .catch(() => {});
if (verif?.profile) { if (verif?.profile) {
clan = verif.profile; clan = verif.profile;
} else if (_guild?.vanityURL) { } else {
const invite = await hf.bot.requestHandler const code =
.request("GET", `${APIEndpoints.INVITE(_guild.vanityURL)}?with_counts=true&with_expiration=true`) _guild?.data?.vanityURL ??
.catch(() => {}); _guild?.data?.store_page?.guild?.invite?.code ??
if (invite?.profile) clan = invite.profile; _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;
}
} }
} }
} }