summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-03 15:27:00 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-03 15:27:00 +0200
commitc944babc9695cd012b4a032b7dd4224ec19003f2 (patch)
treebb8bdc42f5720045017846c7a41ac9ec0b6dae70 /util/src
parent:bug: fix member roles + list (diff)
downloadserver-c944babc9695cd012b4a032b7dd4224ec19003f2.tar.xz
:bug: fix #311
Diffstat (limited to 'util/src')
-rw-r--r--util/src/entities/Guild.ts14
-rw-r--r--util/src/entities/Member.ts10
-rw-r--r--util/src/entities/Template.ts4
-rw-r--r--util/src/interfaces/Event.ts7
4 files changed, 17 insertions, 18 deletions
diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts
index 032a9415..434699ac 100644
--- a/util/src/entities/Guild.ts
+++ b/util/src/entities/Guild.ts
@@ -17,6 +17,8 @@ import { Webhook } from "./Webhook";
 // TODO: stage_instances
 // TODO: threads
 
+export const PublicGuildRelations = ["channels", "emojis", "members", "roles", "stickers", "voice_states"];
+
 @Entity("guilds")
 export class Guild extends BaseClass {
 	@Column({ nullable: true })
@@ -91,9 +93,9 @@ export class Guild extends BaseClass {
 
 	@Column({ nullable: true })
 	@RelationId((guild: Guild) => guild.template)
-	template_id: string;
+	template_id?: string;
 
-	@JoinColumn({ name: "template_id" })
+	@JoinColumn({ name: "template_id", referencedColumnName: "id" })
 	@ManyToOne(() => Template)
 	template: Template;
 
@@ -127,7 +129,7 @@ export class Guild extends BaseClass {
 	@RelationId((guild: Guild) => guild.owner)
 	owner_id: string;
 
-	@JoinColumn([{ name: "owner_id", referencedColumnName: "id" }])
+	@JoinColumn({ name: "owner_id", referencedColumnName: "id" })
 	@ManyToOne(() => User)
 	owner: User;
 
@@ -209,4 +211,10 @@ export class Guild extends BaseClass {
 
 	@Column({ nullable: true })
 	widget_enabled?: boolean;
+
+	@Column({ nullable: true })
+	nsfw_level?: number;
+
+	@Column({ nullable: true })
+	nsfw?: boolean;
 }
diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts
index 76febb50..4cdd3421 100644
--- a/util/src/entities/Member.ts
+++ b/util/src/entities/Member.ts
@@ -26,6 +26,7 @@ import { HTTPError } from "lambert-server";
 import { Role } from "./Role";
 import { Snowflake } from "../util/Snowflake";
 import { BaseClassWithoutId } from "./BaseClass";
+import { PublicGuildRelations } from ".";
 
 @Entity("members")
 @Index(["id", "guild_id"], { unique: true })
@@ -209,7 +210,7 @@ export class Member extends BaseClassWithoutId {
 			where: {
 				id: guild_id,
 			},
-			relations: ["channels", "emojis", "members", "roles", "stickers", "voice_states"],
+			relations: PublicGuildRelations,
 		});
 
 		if (await Member.count({ id: user.id, guild: { id: guild_id } }))
@@ -259,12 +260,7 @@ export class Member extends BaseClassWithoutId {
 					...guild,
 					members: [...guild.members, { ...member, user }],
 					member_count: (guild.member_count || 0) + 1,
-					guild_hashes: {
-						channels: { omitted: false, hash: "nkMQJ5nl5Cg" },
-						metadata: { omitted: false, hash: "+5ybMfcb8iw" },
-						roles: { omitted: false, hash: "Idhc6P9ktfM" },
-						version: 1,
-					},
+					guild_hashes: {},
 					guild_scheduled_events: [],
 					joined_at: member.joined_at,
 					presences: [],
diff --git a/util/src/entities/Template.ts b/util/src/entities/Template.ts
index 76f77ba6..c9c32f42 100644
--- a/util/src/entities/Template.ts
+++ b/util/src/entities/Template.ts
@@ -1,11 +1,11 @@
-import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn, RelationId } from "typeorm";
+import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn, RelationId } from "typeorm";
 import { BaseClass } from "./BaseClass";
 import { Guild } from "./Guild";
 import { User } from "./User";
 
 @Entity("templates")
 export class Template extends BaseClass {
-	@PrimaryColumn()
+	@Column({ unique: true })
 	code: string;
 
 	@Column()
diff --git a/util/src/interfaces/Event.ts b/util/src/interfaces/Event.ts
index acaa822e..2885d62a 100644
--- a/util/src/interfaces/Event.ts
+++ b/util/src/interfaces/Event.ts
@@ -127,12 +127,7 @@ export interface GuildCreateEvent extends Event {
 		joined_at: Date;
 		// TODO: add them to guild
 		guild_scheduled_events: never[];
-		guild_hashes: {
-			channels: { omitted: boolean; hash: string };
-			metadata: { omitted: boolean; hash: string };
-			roles: { omitted: boolean; hash: string };
-			version: number;
-		};
+		guild_hashes: {};
 		presences: never[];
 		stage_instances: never[];
 		threads: never[];