helps to push the other file

This commit is contained in:
Cynthia Foxwell 2024-07-29 20:13:27 -06:00
parent db80e182cc
commit 6fda3ae368

View file

@ -91,6 +91,62 @@ async function getGuild(id, noLocal = false) {
return null;
}
async function tryGetGuild(id) {
const sources = {
local: false,
preview: false,
widget: false,
discovery: false,
verification: false,
clan: false,
};
if (hf.bot.guilds.has(id)) {
sources.local = true;
}
try {
const preview = await hf.bot.requestHandler.request("GET", APIEndpoints.GUILD_PREVIEW(id), true);
if (preview) sources.preview = true;
} catch {
// noop
}
try {
const widget = await hf.bot.requestHandler.request("GET", APIEndpoints.GUILD_WIDGET(id), false);
if (widget) sources.widget = true;
} catch {
// noop
}
try {
const discovery = await hf.bot.requestHandler.request("GET", APIEndpoints.DISCOVERY_SLUG(id), false);
if (discovery) sources.discovery = true;
} catch {
// noop
}
try {
const verification = await hf.bot.requestHandler.request(
"GET",
`${APIEndpoints.GUILD_MEMBER_VERIFICATION(id)}?with_guild=true`,
true
);
if (verification?.guild) sources.verification = true;
} catch {
// noop
}
try {
const clan = await hf.bot.requestHandler.request("GET", APIEndpoints.CLAN(id), true);
if (clan) sources.clan = true;
} catch {
// noop
}
return sources;
}
function enumKeyToName(key) {
return key
.split("_")
@ -165,6 +221,7 @@ module.exports = {
hastebin,
getUploadLimit,
getGuild,
tryGetGuild,
enumKeyToName,
formatGuildFeatures,
getDefaultAvatar,