This commit is contained in:
Flam3rboy
2021-09-04 11:26:47 +02:00
16 changed files with 177 additions and 52 deletions
+37
View File
@@ -16,6 +16,42 @@ import { Webhook } from "./Webhook";
// TODO: guild_scheduled_events
// TODO: stage_instances
// TODO: threads
// TODO: description
// TODO: categories:
// [{
// "id": 16,
// "name": {
// "default": "Anime & Manga",
// "localizations": {
// "de": "Anime & Manga",
// "fr": "Anim\u00e9s et mangas",
// "ru": "\u0410\u043d\u0438\u043c\u0435 \u0438 \u043c\u0430\u043d\u0433\u0430"
// }
// },
// "is_primary": false
// }]
// TODO:
// primary_category :{
// id: 1,
// name: {
// default: "Gaming",
// localizations: { de: "Gaming", fr: "Gaming", ru: "\u0418\u0433\u0440\u044b" },
// is_primary: true,
// },
// };
// TODO:
// "keywords": [
// "Genshin Impact",
// "Paimon",
// "Honkai Impact",
// "ARPG",
// "Open-World",
// "Waifu",
// "Anime",
// "Genshin",
// "miHoYo",
// "Gacha"
// ],
export const PublicGuildRelations = [
"channels",
@@ -66,6 +102,7 @@ export class Guild extends BaseClass {
@Column({ type: "simple-array" })
features: string[]; //TODO use enum
//TODO: https://discord.com/developers/docs/resources/guild#guild-object-guild-features
@Column({ nullable: true })
icon?: string;
+6 -2
View File
@@ -25,7 +25,8 @@ import {
import { HTTPError } from "lambert-server";
import { Role } from "./Role";
import { BaseClassWithoutId } from "./BaseClass";
import { PublicGuildRelations } from ".";
import { Ban, PublicGuildRelations } from ".";
import { DiscordApiErrors } from "../util/Constants";
@Entity("members")
@Index(["id", "guild_id"], { unique: true })
@@ -198,7 +199,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) {