From 628ff5973ea25d155505d2e029d4821425496f3f Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Fri, 3 Sep 2021 05:17:49 +0200 Subject: fix #310 --- util/src/entities/Member.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts index 9ad6c8db..ae60f4e2 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -54,7 +54,7 @@ export class Member extends BaseClassWithoutId { @JoinTable({ name: "member_roles", - joinColumn: { name: "index", referencedColumnName: "index" }, + joinColumn: { name: "id", referencedColumnName: "index" }, inverseJoinColumn: { name: "role_id", referencedColumnName: "id", @@ -119,14 +119,14 @@ export class Member extends BaseClassWithoutId { } static async addRole(user_id: string, guild_id: string, role_id: string) { - const [member] = await Promise.all([ + const [member, role] = await Promise.all([ // @ts-ignore Member.findOneOrFail({ where: { id: user_id, guild_id }, relations: ["user", "roles"], // we don't want to load the role objects just the ids - select: ["roles.id"], + select: ["index", "roles.id"], }), - await Role.findOneOrFail({ id: role_id, guild_id }), + Role.findOneOrFail({ where: { id: role_id, guild_id }, select: ["id"] }), ]); member.roles.push(new Role({ id: role_id })); @@ -150,7 +150,7 @@ export class Member extends BaseClassWithoutId { Member.findOneOrFail({ where: { id: user_id, guild_id }, relations: ["user", "roles"], // we don't want to load the role objects just the ids - select: ["roles.id"], + select: ["roles.id", "index"], }), await Role.findOneOrFail({ id: role_id, guild_id }), ]); -- cgit 1.4.1