feat: check discord entitlements

This commit is contained in:
Naomi Carrigan 2024-06-30 20:08:20 -07:00
parent 7437deab71
commit b64871791d
No known key found for this signature in database
GPG Key ID: 7019A402E94A9808
3 changed files with 2754 additions and 2164 deletions

View File

@ -21,7 +21,7 @@
},
"engines": {
"node": "20",
"pnpm": "8"
"pnpm": "9"
},
"homepage": "https://github.com/nhcarrigan/mod-bot#readme",
"devDependencies": {

4898
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

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
);
};