feat: check discord entitlements

This commit is contained in:
2024-06-30 20:08:20 -07:00
parent 7437deab71
commit b64871791d
3 changed files with 2754 additions and 2164 deletions

View File

@ -13,9 +13,17 @@ import { ExtendedClient } from "../interfaces/ExtendedClient";
export const checkEntitledGuild = async (
bot: ExtendedClient,
guild: Guild
): Promise<boolean> =>
Boolean(
await bot.db.entitlements
.findFirst({ where: { serverId: guild.id } })
.catch(() => null)
): Promise<boolean> => {
const isGuildEntitled = await bot.application?.entitlements
.fetch({
guild,
excludeEnded: true
})
.catch(() => null);
const isManuallyEntitled = await bot.db.entitlements
.findFirst({ where: { serverId: guild.id } })
.catch(() => null);
return Boolean(
(isGuildEntitled && isGuildEntitled.size) || isManuallyEntitled
);
};