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