From 73b167443987c9cb0334d6a2c3d9cf57559e36ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Intevel=20=E3=83=84?= <59223342+Intevel@users.noreply.github.com> Date: Sat, 8 May 2021 13:23:27 +0200 Subject: [PATCH] Update members.ts --- src/routes/guilds/#guild_id/members.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/routes/guilds/#guild_id/members.ts b/src/routes/guilds/#guild_id/members.ts index 0618a567..8e1ce3a3 100644 --- a/src/routes/guilds/#guild_id/members.ts +++ b/src/routes/guilds/#guild_id/members.ts @@ -92,6 +92,26 @@ router.delete("/:member/roles/:role_id", async (req: Request, res: Response) => if (!member) throw new HTTPError("Member not found", 404); await removeRole(user_id, guild_id, role_id); + res.status(204); + + // https://discord.com/developers/docs/resources/guild#remove-guild-member-role +}); + +router.put("/:member/roles/:role_id", async (req: Request, res: Response) => { + + const { guild_id, role_id } = req.params; + if(!role_id) throw new HTTPError("role_id not defined", 404); + + const guild = await GuildModel.findOne({ id: guild_id }).exec(); + if (!guild) throw new HTTPError("Guild not found", 404); + + const user_id = req.params.member; + + const member = await MemberModel.findOne({ id: user_id, guild_id }).exec(); + if (!member) throw new HTTPError("Member not found", 404); + + await addRole(user_id, guild_id, role_id); + res.status(204); // https://discord.com/developers/docs/resources/guild#remove-guild-member-role });