summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 13:09:59 +0200
committerIntevel ツ <59223342+Intevel@users.noreply.github.com>2021-05-08 13:09:59 +0200
commitf5bcde72c6d846e892421eddf933ff3711538296 (patch)
treea8b8d43b8bc8d2ad070c6cf3d07df2d9ddcbfc64 /src
parentUpdate Member.ts (diff)
downloadserver-f5bcde72c6d846e892421eddf933ff3711538296.tar.xz
Update Member.ts
Diffstat (limited to 'src')
-rw-r--r--src/util/Member.ts10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/util/Member.ts b/src/util/Member.ts

index 15520a21..bf48f993 100644 --- a/src/util/Member.ts +++ b/src/util/Member.ts
@@ -124,9 +124,6 @@ export async function removeMember(user_id: string, guild_id: string) { export async function addRole(user_id: string, guild_id: string, role_id: string) { const user = await getPublicUser(user_id); - const guild = await GuildModel.findOne({ id: guild_id }).exec(); - if (!guild) throw new HTTPError("Guild not found", 404); - const role = await RoleModel.findOne({ id: role_id, guild_id: guild_id }).exec(); if (!role) throw new HTTPError("role not found", 404); @@ -135,7 +132,7 @@ export async function addRole(user_id: string, guild_id: string, role_id: string guild_id: guild_id, }, { $push: { roles: role_id } }).exec(); - if(!memberObj) throw new Error("Internal server error"); + if(!memberObj) throw new HTTPError("Member not found", 404); await emitEvent({ event: "GUILD_MEMBER_UPDATE", @@ -153,9 +150,6 @@ export async function addRole(user_id: string, guild_id: string, role_id: string export async function removeRole(user_id: string, guild_id: string, role_id: string) { const user = await getPublicUser(user_id); - const guild = await GuildModel.findOne({ id: guild_id }).exec(); - if (!guild) throw new HTTPError("Guild not found", 404); - const role = await RoleModel.findOne({ id: role_id, guild_id: guild_id }).exec(); if (!role) throw new HTTPError("role not found", 404); @@ -164,7 +158,7 @@ export async function removeRole(user_id: string, guild_id: string, role_id: str guild_id: guild_id, }, { $pull: { roles: role_id } }).exec(); - if(!memberObj) throw new Error("Internal server error"); + if(!memberObj) throw new HTTPError("Member not found", 404); await emitEvent({ event: "GUILD_MEMBER_UPDATE",