diff options
author | Puyodead1 <puyodead@proton.me> | 2023-12-20 03:33:28 -0500 |
---|---|---|
committer | Puyodead1 <puyodead@proton.me> | 2023-12-20 03:33:28 -0500 |
commit | e34887261f8d86aa4e98f4b8ccd6e57ce72c6620 (patch) | |
tree | b7cb601c7e818349b3000eaf20bc75e44c22ff87 /src/api/routes/guilds/#guild_id/roles/index.ts | |
parent | add missing license headers (diff) | |
download | server-feat/admin-api.tar.xz |
initial progress for admin api feat/admin-api
Diffstat (limited to 'src/api/routes/guilds/#guild_id/roles/index.ts')
-rw-r--r-- | src/api/routes/guilds/#guild_id/roles/index.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/api/routes/guilds/#guild_id/roles/index.ts b/src/api/routes/guilds/#guild_id/roles/index.ts index e2c34e7f..4f56232d 100644 --- a/src/api/routes/guilds/#guild_id/roles/index.ts +++ b/src/api/routes/guilds/#guild_id/roles/index.ts @@ -49,6 +49,7 @@ router.post( route({ requestBody: "RoleModifySchema", permission: "MANAGE_ROLES", + right: "OPERATOR", responses: { 200: { body: "Role", @@ -65,11 +66,14 @@ router.post( const guild_id = req.params.guild_id; const body = req.body as RoleModifySchema; - const role_count = await Role.count({ where: { guild_id } }); - const { maxRoles } = Config.get().limits.guild; + // admins can bypass this + if (!req.has_right) { + const role_count = await Role.count({ where: { guild_id } }); + const { maxRoles } = Config.get().limits.guild; - if (role_count > maxRoles) - throw DiscordApiErrors.MAXIMUM_ROLES.withParams(maxRoles); + if (role_count > maxRoles) + throw DiscordApiErrors.MAXIMUM_ROLES.withParams(maxRoles); + } const role = Role.create({ // values before ...body are default and can be overriden |