mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-06 10:52:31 +01:00
fix(api): prevent @everyone role duplication
If user already has @everyone role, then don't push it to the array
This commit is contained in:
parent
4a617faf02
commit
b20746bd17
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user