From 94c1f9f74b86849c162496259278f3d1fc875418 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:22 +0200 Subject: [PATCH] Update Member.ts --- src/util/Member.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/util/Member.ts b/src/util/Member.ts index fca3de95..1a66b60e 100644 --- a/src/util/Member.ts +++ b/src/util/Member.ts @@ -173,4 +173,27 @@ export async function removeRole(user_id: string, guild_id: string, role_id: str } +export async function changeNickname(user_id: string, guild_id: string, nickname: string) { + const user = await getPublicUser(user_id); + + var memberObj = await MemberModel.findOneAndUpdate({ + id: user_id, + guild_id: guild_id, + }, { nick: nickname } ).exec(); + + if(!memberObj) throw new HTTPError("Member not found", 404); + + await emitEvent({ + event: "GUILD_MEMBER_UPDATE", + data: { + guild_id: guild_id, + user: user, + nick: nickname + + }, + guild_id: guild_id, + } as GuildMemberUpdateEvent); + +} +