From cbf02c67ecdf9cca61bfc100f703a85e2ca409c0 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:49:19 +0200 Subject: [PATCH] Update members.ts --- src/routes/guilds/#guild_id/members.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/guilds/#guild_id/members.ts b/src/routes/guilds/#guild_id/members.ts index 5aaf3ec0..c8dddfe5 100644 --- a/src/routes/guilds/#guild_id/members.ts +++ b/src/routes/guilds/#guild_id/members.ts @@ -2,7 +2,7 @@ import { Request, Response, Router } from "express"; import { GuildModel, MemberModel, UserModel, toObject, GuildMemberAddEvent, getPermission } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { instanceOf, Length } from "../../../util/instanceOf"; -import { PublicMemberProjection, addMember, removeMember, addRole, removeRole } from "../../../util/Member"; +import { PublicMemberProjection, addMember, removeMember, addRole, removeRole, changeNickname } from "../../../util/Member"; import { emitEvent } from "../../../util/Event"; import { getPublicUser } from "../../../util/User"; @@ -81,13 +81,14 @@ router.put("/:member_id/roles/:role_id", async (req: Request, res: Response) => res.sendStatus(204); }); -router.patch("/:member_id/@me/nick", async (req: Request, res: Response) => { +router.patch("/:member_id/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"); - //await addRole(member_id, guild_id, role_id); + await changeNickname(member_id, guild_id, req.body.nickname); res.status(204); });