guildinfo: get profile from existing guild invites if possible

This commit is contained in:
Cynthia Foxwell 2025-05-06 22:48:22 -06:00
parent 593edb2f8e
commit 8f5a5914ba
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -83,7 +83,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
if (verif?.profile) {
clan = verif.profile;
} else {
const code =
let code =
_guild?.data?.vanityURL ??
_guild?.data?.store_page?.guild?.invite?.code ??
_guild?.data?.store_page?.role_subscription?.purchase_page_invite?.code ??
@ -91,6 +91,13 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
/(https?:\/\/)?(canary\.|ptb\.)?discord(\.gg|(app)?.com\/invite)\//,
""
);
if (!code && hf.bot.guilds.has(id)) {
const invites = await hf.bot.requestHandler
.request("GET", APIEndpoints.GUILD_INVITES(id), true)
.catch(() => {});
if (invites?.[0]?.code) code = invites[0].code;
}
if (code) {
const invite = await hf.bot.requestHandler
.request("GET", `${APIEndpoints.INVITE(code)}?with_counts=true&with_expiration=true`)