generated from nhcarrigan/template
feat: check discord entitlements
This commit is contained in:
parent
7437deab71
commit
b64871791d
@ -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
4898
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user