diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-03 05:17:49 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-03 05:17:49 +0200 |
commit | 628ff5973ea25d155505d2e029d4821425496f3f (patch) | |
tree | 6a75fbd335330aeabdbf259a5bfc6c965cbbd2f1 /util/src/entities | |
parent | :zap: simplify permissions query (diff) | |
download | server-628ff5973ea25d155505d2e029d4821425496f3f.tar.xz |
fix #310
Diffstat (limited to 'util/src/entities')
-rw-r--r-- | util/src/entities/Member.ts | 10 |
1 files changed, 5 insertions, 5 deletions
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 }), ]); |