From 620f9339f0737b79d72c66d90ffa42ea3f987710 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Wed, 31 Jul 2024 19:30:30 +0700 Subject: [PATCH] feat(bots/discord): allow admins to bypass permission checks --- bots/discord/src/classes/Command.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bots/discord/src/classes/Command.ts b/bots/discord/src/classes/Command.ts index 7baf466..f02a573 100644 --- a/bots/discord/src/classes/Command.ts +++ b/bots/discord/src/classes/Command.ts @@ -291,6 +291,9 @@ export default class Command< async canExecute(executor: User | GuildMember, channelId: string): Promise { if (!this.requirements) return false + const isExecutorAdmin = isAdmin(executor) + if (isExecutorAdmin) return true + const { adminOnly, channels, @@ -307,7 +310,7 @@ export default class Command< const bMemReqForUsers = memberRequirementsForUsers !== 'fail' const conditions = [ - adminOnly ? isAdmin(executor) : bDefCond, + adminOnly ? isExecutorAdmin : bDefCond, channels ? channels.includes(channelId) : bDefCond, member ? (roles ? roles.some(role => member.roles.cache.has(role)) : bDefCond) : bMemReqForUsers, member ? (permissions ? member.permissions.has(permissions) : bDefCond) : bMemReqForUsers,