summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-04-29 01:42:08 -0700
committerFuwn <[email protected]>2026-04-29 01:42:08 -0700
commitcb8e450d7d5ec99d360558887e79f77da164971e (patch)
tree3ad9f2fc367cff904cec96646969248da6636098
parentrefactor(interactions:server): Split role allowlist into general and privileg... (diff)
downloadumabotdiscord-cb8e450d7d5ec99d360558887e79f77da164971e.tar.xz
umabotdiscord-cb8e450d7d5ec99d360558887e79f77da164971e.zip
feat(interactions:server): Allow moderators to use role command with general allowlist
-rw-r--r--packages/interactions/server.ts20
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: {