diff options
| -rw-r--r-- | packages/interactions/server.ts | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/packages/interactions/server.ts b/packages/interactions/server.ts index 5257e5e..890acf4 100644 --- a/packages/interactions/server.ts +++ b/packages/interactions/server.ts @@ -873,13 +873,19 @@ router.post("/", async (request: Request, environment: Environment) => { roleId as any, ), ); - - if (!hasAdminPermission && !hasOwnerRole && !hasAdministratorRole) + const hasModeratorRole = member?.roles?.includes(MODERATOR_ROLE_ID); + + if ( + !hasAdminPermission && + !hasOwnerRole && + !hasAdministratorRole && + !hasModeratorRole + ) return new JSONResponse({ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, data: { content: - "❌ You don't have permission to use this command. Only server administrators can use this command.", + "❌ You don't have permission to use this command. Only server administrators and moderators can use this command.", flags: 64, }, }); @@ -910,7 +916,13 @@ router.post("/", async (request: Request, environment: Environment) => { }, }); - if (!ALLOWED_PRIVILEGED_ROLE_IDS.includes(targetRoleID)) + const isPrivileged = + hasAdminPermission || hasOwnerRole || hasAdministratorRole; + const allowedRoleIDs = isPrivileged + ? ALLOWED_PRIVILEGED_ROLE_IDS + : ALLOWED_ROLE_IDS; + + if (!allowedRoleIDs.includes(targetRoleID)) return new JSONResponse({ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, data: { |