summary refs log tree commit diff
path: root/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-03 13:10:24 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-03 13:10:24 +0200
commit2fab755e97c9f1e60d1198a260f3081cd5408b79 (patch)
tree5a6deaaf33069aff6c5e7ddc1aed849f57041e9f /util
parent:bug: fix client connection crash on guild create (diff)
downloadserver-2fab755e97c9f1e60d1198a260f3081cd5408b79.tar.xz
:bug: fix member has no roles in guild create
Diffstat (limited to 'util')
-rw-r--r--util/src/entities/Member.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts
index db4e827b..76febb50 100644
--- a/util/src/entities/Member.ts
+++ b/util/src/entities/Member.ts
@@ -54,13 +54,14 @@ export class Member extends BaseClassWithoutId {
 
 	@JoinTable({
 		name: "member_roles",
-		joinColumn: { name: "id", referencedColumnName: "index" },
+
+		joinColumn: { name: "index", referencedColumnName: "index" },
 		inverseJoinColumn: {
 			name: "role_id",
 			referencedColumnName: "id",
 		},
 	})
-	@ManyToMany(() => Role)
+	@ManyToMany(() => Role, { cascade: true })
 	roles: Role[];
 
 	@Column()
@@ -227,7 +228,7 @@ export class Member extends BaseClassWithoutId {
 		};
 
 		await Promise.all([
-			Member.insert({
+			new Member({
 				...member,
 				roles: [new Role({ id: guild_id })],
 				// read_state: {},
@@ -240,7 +241,8 @@ export class Member extends BaseClassWithoutId {
 					suppress_roles: false,
 					version: 0,
 				},
-			}),
+				// Member.save is needed because else the roles relations wouldn't be updated
+			}).save(),
 			Guild.increment({ id: guild_id }, "member_count", 1),
 			emitEvent({
 				event: "GUILD_MEMBER_ADD",