summary refs log tree commit diff
path: root/src/routes
diff options
context:
space:
mode:
authorIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 13:52:58 +0200
committerIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 13:52:58 +0200
commit3d79ed6a6b86e2045e3679652bf5c714507effa5 (patch)
tree8b9177397e30c222f3659620d13b8f9905045a62 /src/routes
parentUpdate Member.ts (diff)
downloadserver-3d79ed6a6b86e2045e3679652bf5c714507effa5.tar.xz
Update members.ts
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/guilds/#guild_id/members.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/routes/guilds/#guild_id/members.ts b/src/routes/guilds/#guild_id/members.ts
index c8dddfe5..005a4142 100644
--- a/src/routes/guilds/#guild_id/members.ts
+++ b/src/routes/guilds/#guild_id/members.ts
@@ -92,5 +92,19 @@ router.patch("/:member_id/nick", async (req: Request, res: Response) => {
 	res.status(204);
 });
 
+router.patch("/members/@me/nick", async (req: Request, res: Response) => {
+	const { guild_id, member_id } = req.params;
+	if(!req.body.nickname) throw new HTTPError("No nickname defined", 404);
+
+	const perms = await getPermission(member_id, guild_id);
+	perms.hasThrow("CHANGE_NICKNAME");
+
+	const member = await MemberModel.findOne({ id: req.user_id }).exec();
+	if (!member) throw new HTTPError("Member not found", 404);
+
+	await changeNickname(member_id, guild_id, req.body.nickname);
+	res.status(204);
+});
+
 
 export default router;