summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
authorxnacly <matteogropp@protonmail.com>2021-09-03 21:31:45 +0200
committerxnacly <matteogropp@protonmail.com>2021-09-03 21:31:45 +0200
commit89da09f15213d5f2cd9144475ae041c649090feb (patch)
treeb87115d21eace4e36809d58eb73a563e607a2693 /util/src
parentmoved Constants and Errorhandler from api to util (diff)
downloadserver-89da09f15213d5f2cd9144475ae041c649090feb.tar.xz
added ban check to `Member.addToGuild`
Diffstat (limited to 'util/src')
-rw-r--r--util/src/entities/Member.ts8
1 files changed, 6 insertions, 2 deletions
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) {