diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-05-10 18:03:20 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-05-10 18:03:20 +0200 |
commit | f526bbdcbc4e541c0797fb5abc1cd70ce68a9f30 (patch) | |
tree | 6b628346a7bc2eacc7393cf10918eda11f1db035 | |
parent | Update package.json (diff) | |
download | server-f526bbdcbc4e541c0797fb5abc1cd70ce68a9f30.tar.xz |
:bug: fix Database toObject
-rw-r--r-- | src/util/Database.ts | 2 | ||||
-rw-r--r-- | src/util/Permissions.ts | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/util/Database.ts b/src/util/Database.ts index 339ac65b..68909c97 100644 --- a/src/util/Database.ts +++ b/src/util/Database.ts @@ -18,6 +18,8 @@ export default <Connection>connection; function transform<T>(document: T) { // @ts-ignore + if (!document || !document.toObject) return document; + // @ts-ignore return document.toObject({ virtuals: true }); } diff --git a/src/util/Permissions.ts b/src/util/Permissions.ts index 8debfa08..6b29248c 100644 --- a/src/util/Permissions.ts +++ b/src/util/Permissions.ts @@ -211,9 +211,7 @@ export async function getPermission( if (!member) member = await MemberModel.findOne({ guild_id, id: user_id }, "roles").exec(); if (!member) throw new Error("Member not found"); - roles = await RoleModel.find({ guild_id, id: { $in: member.roles } }) - .lean() - .exec(); + roles = await RoleModel.find({ guild_id, id: { $in: member.roles } }).exec(); } var permission = Permissions.finalPermission({ |