From 89da09f15213d5f2cd9144475ae041c649090feb Mon Sep 17 00:00:00 2001 From: xnacly Date: Fri, 3 Sep 2021 21:31:45 +0200 Subject: added ban check to `Member.addToGuild` --- util/src/entities/Member.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'util/src/entities/Member.ts') diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts index 4cdd3421..8f391af3 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -26,7 +26,8 @@ import { HTTPError } from "lambert-server"; import { Role } from "./Role"; import { Snowflake } from "../util/Snowflake"; import { BaseClassWithoutId } from "./BaseClass"; -import { PublicGuildRelations } from "."; +import { Ban, PublicGuildRelations } from "."; +import { DiscordApiErrors } from "../util/Constants"; @Entity("members") @Index(["id", "guild_id"], { unique: true }) @@ -199,7 +200,10 @@ export class Member extends BaseClassWithoutId { static async addToGuild(user_id: string, guild_id: string) { const user = await User.getPublicUser(user_id); - + const isBanned = await Ban.count({ where: { guild_id, user_id } }); + if (isBanned) { + throw DiscordApiErrors.USER_BANNED; + } const { maxGuilds } = Config.get().limits.user; const guild_count = await Member.count({ id: user_id }); if (guild_count >= maxGuilds) { -- cgit 1.4.1