mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-06 10:52:31 +01:00
fix(api): always add @everyone in user's roles
When you add or delete an user's role, you MUST always add "@everyone" role to the roles map
This commit is contained in:
parent
22467f2596
commit
4a617faf02
@ -28,6 +28,9 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re
|
|||||||
|
|
||||||
if (body.roles) {
|
if (body.roles) {
|
||||||
permission.hasThrow("MANAGE_ROLES");
|
permission.hasThrow("MANAGE_ROLES");
|
||||||
|
|
||||||
|
const everyone = await Role.findOneOrFail({ guild_id: guild_id, name: "@everyone", position: 0 });
|
||||||
|
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
|
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