From 022f629921a2d3f82cd83f6adfb3d1d0b0579554 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 15 Nov 2025 00:27:42 +0100 Subject: [PATCH] feat(lib/perm): adding the functions isOwner / isBuyer - Those functions will permit more portabilities to the code to check if a user can perform an action or not --- src/lib/perm.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/lib/perm.ts b/src/lib/perm.ts index be4816e..8e3c44d 100644 --- a/src/lib/perm.ts +++ b/src/lib/perm.ts @@ -28,3 +28,35 @@ export async function isWhitelisted(userId: string, guildId: string): Promise { + if (client.user?.id == userId) { + return true; + } + const userData: UserPrisma = await prisma.user.findUnique({ + where: { + id: userId, + }, + }); + return (userData.isDev || userData.isOwner || userData.isBuyer); +} + +/** + * @param userId - Discord identifier for the user + * @returns true if the user is whitelisted flase overwise + */ +export async function isBuyer(userId: string): Promise { + if (client.user?.id == userId) { + return true; + } + const userData: UserPrisma = await prisma.user.findUnique({ + where: { + id: userId, + }, + }); + return (userData.isDev || userData.isBuyer); +}