From cb8e450d7d5ec99d360558887e79f77da164971e Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 29 Apr 2026 01:42:08 -0700 Subject: feat(interactions:server): Allow moderators to use role command with general allowlist --- packages/interactions/server.ts | 20 ++++++++++++++++---- 1 file 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: { -- cgit v1.2.3