diff options
author | Nobody <git@n0bodysec.com> | 2022-03-08 09:25:14 -0300 |
---|---|---|
committer | Erkin Alp Güney <erkinalp9035@gmail.com> | 2022-03-08 18:07:28 +0300 |
commit | d46fe195d00bcd87ed9936b29ca5aef058e90fe2 (patch) | |
tree | 287301bd9fc82211f1f9d3a2cf0f898670a4c65c /api/src/routes/guilds/#guild_id | |
parent | fix(api): always add @everyone in user's roles (diff) | |
download | server-d46fe195d00bcd87ed9936b29ca5aef058e90fe2.tar.xz |
fix(api): prevent @everyone role duplication
If user already has @everyone role, then don't push it to the array
Diffstat (limited to 'api/src/routes/guilds/#guild_id')
-rw-r--r-- | api/src/routes/guilds/#guild_id/members/#member_id/index.ts | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts index c33eb2fe..3234a405 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts +++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts @@ -30,7 +30,7 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re permission.hasThrow("MANAGE_ROLES"); const everyone = await Role.findOneOrFail({ guild_id: guild_id, name: "@everyone", position: 0 }); - body.roles.push(everyone?.id); + if (body.roles.indexOf(everyone.id) === -1) body.roles.push(everyone.id); member.roles = body.roles.map((x) => new Role({ id: x })); // foreign key constraint will fail if role doesn't exist } |