mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 20:52:42 +01:00
fix member roles
This commit is contained in:
parent
42a50c0674
commit
1c897af1be
@ -14,8 +14,8 @@ router.get("/", async (req: Request, res: Response) => {
|
||||
|
||||
const [guild, member_count, member] = await Promise.all([
|
||||
Guild.findOneOrFail({ id: guild_id }),
|
||||
Member.count({ guild_id: guild_id, id: req.user_id }),
|
||||
Member.findOneOrFail(req.user_id)
|
||||
Member.count({ guild: { id: guild_id }, id: req.user_id }),
|
||||
Member.findOneOrFail({ id: req.user_id })
|
||||
]);
|
||||
if (!member_count) throw new HTTPError("You are not a member of the guild you are trying to access", 401);
|
||||
|
||||
|
@ -43,7 +43,7 @@ router.patch("/", check(MemberChangeSchema), async (req: Request, res: Response)
|
||||
emitEvent({
|
||||
event: "GUILD_MEMBER_UPDATE",
|
||||
guild_id,
|
||||
data: { ...member, roles: member.role_ids }
|
||||
data: { ...member, roles: member.roles.map((x) => x.id) }
|
||||
} as GuildMemberUpdateEvent)
|
||||
]);
|
||||
|
||||
|
@ -91,7 +91,7 @@ router.patch("/:role_id", check(RoleModifySchema), async (req: Request, res: Res
|
||||
const perms = await getPermission(req.user_id, guild_id);
|
||||
perms.hasThrow("MANAGE_ROLES");
|
||||
|
||||
const role = new Role({ ...body, role_id, guild_id, permissions: perms.bitfield & (body.permissions || 0n) });
|
||||
const role = new Role({ ...body, id: role_id, guild_id, permissions: perms.bitfield & (body.permissions || 0n) });
|
||||
|
||||
await Promise.all([
|
||||
role.save(),
|
||||
|
Loading…
Reference in New Issue
Block a user