diff options
author | xnacly <matteogropp@protonmail.com> | 2021-09-03 21:31:45 +0200 |
---|---|---|
committer | xnacly <matteogropp@protonmail.com> | 2021-09-03 21:31:45 +0200 |
commit | 89da09f15213d5f2cd9144475ae041c649090feb (patch) | |
tree | b87115d21eace4e36809d58eb73a563e607a2693 /util/src | |
parent | moved Constants and Errorhandler from api to util (diff) | |
download | server-89da09f15213d5f2cd9144475ae041c649090feb.tar.xz |
added ban check to `Member.addToGuild`
Diffstat (limited to 'util/src')
-rw-r--r-- | util/src/entities/Member.ts | 8 |
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) { |