From e5f408be0889562f6fa36ac1bb1730e50bf1951f Mon Sep 17 00:00:00 2001
From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com>
Date: Tue, 6 Apr 2021 03:56:19 +0200
Subject: [PATCH] :bug: fix Database
---
dist/models/Activity.d.ts | 66 +++++++++++-----------
dist/models/Activity.js | 52 ++++++++---------
dist/models/Activity.js.map | 2 +-
dist/models/Event.d.ts | 25 +++++++--
dist/models/Event.js.map | 2 +-
dist/models/Guild.js | 39 ++++++++++++-
dist/models/Guild.js.map | 2 +-
dist/models/User.d.ts | 16 +++---
dist/models/User.js | 52 ++++++++---------
dist/models/User.js.map | 2 +-
dist/util/Database.d.ts | 6 +-
dist/util/Database.js | 105 ++++++++++++++++++-----------------
dist/util/Database.js.map | 2 +-
dist/util/Permissions.js | 4 +-
dist/util/Permissions.js.map | 2 +-
src/util/Database.ts | 58 ++++++++++---------
src/util/Permissions.ts | 4 +-
17 files changed, 255 insertions(+), 184 deletions(-)
diff --git a/dist/models/Activity.d.ts b/dist/models/Activity.d.ts
index 6a97a871..dfa0815e 100644
--- a/dist/models/Activity.d.ts
+++ b/dist/models/Activity.d.ts
@@ -12,10 +12,10 @@ export interface Activity {
name: string;
type: ActivityType;
url?: string;
- created_at: Date;
+ created_at?: Date;
timestamps?: {
- start: number;
- end: number;
+ start?: number;
+ end?: number;
}[];
application_id?: bigint;
details?: string;
@@ -30,10 +30,10 @@ export interface Activity {
size?: [number, number];
};
assets?: {
- large_image: string;
- large_text: string;
- small_image: string;
- small_text: string;
+ large_image?: string;
+ large_text?: string;
+ small_image?: string;
+ small_text?: string;
};
secrets?: {
join?: string;
@@ -46,37 +46,37 @@ export interface Activity {
export declare const Activity: {
name: StringConstructor;
type: NumberConstructor;
- url: StringConstructor;
- created_at: DateConstructor;
- timestamps: {
- start: NumberConstructor;
- end: NumberConstructor;
+ $url: StringConstructor;
+ $created_at: DateConstructor;
+ $timestamps: {
+ $start: NumberConstructor;
+ $end: NumberConstructor;
}[];
- application_id: typeof Types.Long;
- details: StringConstructor;
- state: StringConstructor;
- emoji: {
- name: StringConstructor;
- id: typeof Types.Long;
- amimated: BooleanConstructor;
+ $application_id: typeof Types.Long;
+ $details: StringConstructor;
+ $state: StringConstructor;
+ $emoji: {
+ $name: StringConstructor;
+ $id: typeof Types.Long;
+ $amimated: BooleanConstructor;
};
- party: {
- id: StringConstructor;
- size: NumberConstructor[];
+ $party: {
+ $id: StringConstructor;
+ $size: NumberConstructor[];
};
- assets: {
- large_image: StringConstructor;
- large_text: StringConstructor;
- small_image: StringConstructor;
- small_text: StringConstructor;
+ $assets: {
+ $large_image: StringConstructor;
+ $large_text: StringConstructor;
+ $small_image: StringConstructor;
+ $small_text: StringConstructor;
};
- secrets: {
- join: StringConstructor;
- spectate: StringConstructor;
- match: StringConstructor;
+ $secrets: {
+ $join: StringConstructor;
+ $spectate: StringConstructor;
+ $match: StringConstructor;
};
- instance: BooleanConstructor;
- flags: typeof Types.Long;
+ $instance: BooleanConstructor;
+ $flags: typeof Types.Long;
};
export declare enum ActivityType {
GAME = 0,
diff --git a/dist/models/Activity.js b/dist/models/Activity.js
index fe85ac65..020856db 100644
--- a/dist/models/Activity.js
+++ b/dist/models/Activity.js
@@ -5,39 +5,39 @@ const mongoose_1 = require("mongoose");
exports.Activity = {
name: String,
type: Number,
- url: String,
- created_at: Date,
- timestamps: [
+ $url: String,
+ $created_at: Date,
+ $timestamps: [
{
- start: Number,
- end: Number,
+ $start: Number,
+ $end: Number,
},
],
- application_id: mongoose_1.Types.Long,
- details: String,
- state: String,
- emoji: {
- name: String,
- id: mongoose_1.Types.Long,
- amimated: Boolean,
+ $application_id: mongoose_1.Types.Long,
+ $details: String,
+ $state: String,
+ $emoji: {
+ $name: String,
+ $id: mongoose_1.Types.Long,
+ $amimated: Boolean,
},
- party: {
- id: String,
- size: [Number, Number],
+ $party: {
+ $id: String,
+ $size: [Number, Number],
},
- assets: {
- large_image: String,
- large_text: String,
- small_image: String,
- small_text: String,
+ $assets: {
+ $large_image: String,
+ $large_text: String,
+ $small_image: String,
+ $small_text: String,
},
- secrets: {
- join: String,
- spectate: String,
- match: String,
+ $secrets: {
+ $join: String,
+ $spectate: String,
+ $match: String,
},
- instance: Boolean,
- flags: mongoose_1.Types.Long,
+ $instance: Boolean,
+ $flags: mongoose_1.Types.Long,
};
var ActivityType;
(function (ActivityType) {
diff --git a/dist/models/Activity.js.map b/dist/models/Activity.js.map
index c27ae387..786f0184 100644
--- a/dist/models/Activity.js.map
+++ b/dist/models/Activity.js.map
@@ -1 +1 @@
-{"version":3,"file":"Activity.js","sourceRoot":"","sources":["../../src/models/Activity.ts"],"names":[],"mappings":";;;AAEA,uCAA0D;AA8C7C,QAAA,QAAQ,GAAG;IACvB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE;QACX;YACC,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,MAAM;SACX;KACD;IACD,cAAc,EAAE,gBAAK,CAAC,IAAI;IAC1B,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,MAAM;IACb,KAAK,EAAE;QACN,IAAI,EAAE,MAAM;QACZ,EAAE,EAAE,gBAAK,CAAC,IAAI;QACd,QAAQ,EAAE,OAAO;KACjB;IACD,KAAK,EAAE;QACN,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;KACtB;IACD,MAAM,EAAE;QACP,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,MAAM;KAClB;IACD,OAAO,EAAE;QACR,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,MAAM;KACb;IACD,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,gBAAK,CAAC,IAAI;CACjB,CAAC;AAEF,IAAY,YAMX;AAND,WAAY,YAAY;IACvB,+CAAQ,CAAA;IACR,yDAAa,CAAA;IACb,yDAAa,CAAA;IACb,mDAAU,CAAA;IACV,yDAAa,CAAA;AACd,CAAC,EANW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAMvB"}
\ No newline at end of file
+{"version":3,"file":"Activity.js","sourceRoot":"","sources":["../../src/models/Activity.ts"],"names":[],"mappings":";;;AAEA,uCAA0D;AA8C7C,QAAA,QAAQ,GAAG;IACvB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE;QACZ;YACC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACZ;KACD;IACD,eAAe,EAAE,gBAAK,CAAC,IAAI;IAC3B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE;QACP,KAAK,EAAE,MAAM;QACb,GAAG,EAAE,gBAAK,CAAC,IAAI;QACf,SAAS,EAAE,OAAO;KAClB;IACD,MAAM,EAAE;QACP,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;KACvB;IACD,OAAO,EAAE;QACR,YAAY,EAAE,MAAM;QACpB,WAAW,EAAE,MAAM;QACnB,YAAY,EAAE,MAAM;QACpB,WAAW,EAAE,MAAM;KACnB;IACD,QAAQ,EAAE;QACT,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,MAAM;QACjB,MAAM,EAAE,MAAM;KACd;IACD,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,gBAAK,CAAC,IAAI;CAClB,CAAC;AAEF,IAAY,YAMX;AAND,WAAY,YAAY;IACvB,+CAAQ,CAAA;IACR,yDAAa,CAAA;IACb,yDAAa,CAAA;IACb,mDAAU,CAAA;IACV,yDAAa,CAAA;AACd,CAAC,EANW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAMvB"}
\ No newline at end of file
diff --git a/dist/models/Event.d.ts b/dist/models/Event.d.ts
index e4a1517b..e00c2a97 100644
--- a/dist/models/Event.d.ts
+++ b/dist/models/Event.d.ts
@@ -1,8 +1,8 @@
///
-import { ConnectedAccount, User, UserSettings } from "./User";
+import { ConnectedAccount, PublicUser, User, UserSettings } from "./User";
import { DMChannel, Channel } from "./Channel";
import { Guild } from "./Guild";
-import { PublicMember, UserGuildSettings } from "./Member";
+import { Member, PublicMember, UserGuildSettings } from "./Member";
import { Emoji } from "./Emoji";
import { Presence } from "./Activity";
import { Role } from "./Role";
@@ -29,7 +29,19 @@ export interface InvalidatedEvent extends Event {
}
export interface ReadyEventData {
v: number;
- user: Omit;
+ user: PublicUser & {
+ mobile: boolean;
+ desktop: boolean;
+ email: string;
+ flags: bigint;
+ mfa_enabled: boolean;
+ nsfw_allowed: boolean;
+ phone: string;
+ premium: boolean;
+ premium_type: number;
+ verified: boolean;
+ bot: boolean;
+ };
private_channels: DMChannel[];
session_id: string;
guilds: Guild[];
@@ -67,6 +79,11 @@ export interface ReadyEventData {
shard?: [number, number];
user_settings?: UserSettings;
relationships?: [];
+ read_state: {
+ entries: [];
+ partial: boolean;
+ version: number;
+ };
user_guild_settings?: {
entries: UserGuildSettings[];
version: number;
@@ -76,7 +93,7 @@ export interface ReadyEventData {
id: bigint;
flags: bigint;
};
- merged_members?: PublicMember[][];
+ merged_members?: Omit[][];
users?: {
avatar?: string;
discriminator: string;
diff --git a/dist/models/Event.js.map b/dist/models/Event.js.map
index 1453ecc1..268c8597 100644
--- a/dist/models/Event.js.map
+++ b/dist/models/Event.js.map
@@ -1 +1 @@
-{"version":3,"file":"Event.js","sourceRoot":"","sources":["../../src/models/Event.ts"],"names":[],"mappings":";;;;;;AAYA,uCAA0D;AAC1D,gEAAkC;AAarB,QAAA,WAAW,GAAG,IAAI,iBAAM,CAAC;IACrC,QAAQ,EAAE,gBAAK,CAAC,IAAI;IACpB,OAAO,EAAE,gBAAK,CAAC,IAAI;IACnB,UAAU,EAAE,gBAAK,CAAC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D,CAAA;IACxD,yEAA4D,CAAA;IAC5D,+CAAkC,CAAA;IAClC,yCAA4B,CAAA;IAC5B,uCAA0B,CAAA;IAC1B,+CAAkC,CAAA;IAClC,qDAAwC,CAAA;IACxC,oDAAuC,CAAA;IACvC,sDAAyC,CAAA;IACzC,oEAAuD,CAAA;IACvD,oEAAuD,CAAA;IACvD,oEAAuD,CAAA;AACxD,CAAC,EAzCW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAyCpB"}
\ No newline at end of file
diff --git a/dist/models/Guild.js b/dist/models/Guild.js
index a2d0d114..6a8adfc5 100644
--- a/dist/models/Guild.js
+++ b/dist/models/Guild.js
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.GuildModel = exports.GuildSchema = void 0;
const mongoose_1 = require("mongoose");
const Database_1 = __importDefault(require("../util/Database"));
+const Channel_1 = require("./Channel");
+const Emoji_1 = require("./Emoji");
+const Member_1 = require("./Member");
+const Role_1 = require("./Role");
exports.GuildSchema = new mongoose_1.Schema({
id: { type: mongoose_1.Types.Long, required: true },
afk_channel_id: mongoose_1.Types.Long,
@@ -44,7 +48,40 @@ exports.GuildSchema = new mongoose_1.Schema({
widget_channel_id: mongoose_1.Types.Long,
widget_enabled: Boolean,
});
-// GuildSchema.virtual
+exports.GuildSchema.virtual("channels", {
+ ref: Channel_1.ChannelModel,
+ localField: "id",
+ foreignField: "guild_id",
+ justOne: false,
+});
+exports.GuildSchema.virtual("roles", {
+ ref: Role_1.RoleModel,
+ localField: "id",
+ foreignField: "guild_id",
+ justOne: false,
+});
+// nested populate is needed for member users: https://gist.github.com/yangsu/5312204
+exports.GuildSchema.virtual("members", {
+ ref: Member_1.MemberModel,
+ localField: "id",
+ foreignField: "member_id",
+ justOne: false,
+});
+exports.GuildSchema.virtual("emojis", {
+ ref: Emoji_1.EmojiModel,
+ localField: "id",
+ foreignField: "guild_id",
+ justOne: false,
+});
+exports.GuildSchema.virtual("joined_at", {
+ ref: Member_1.MemberModel,
+ localField: "id",
+ foreignField: "guild_id",
+ justOne: true,
+}).get((member, virtual, doc) => {
+ console.log("get", member, this);
+ return member.joined_at;
+});
// @ts-ignore
exports.GuildModel = Database_1.default.model("Guild", exports.GuildSchema, "guilds");
//# sourceMappingURL=Guild.js.map
\ No newline at end of file
diff --git a/dist/models/Guild.js.map b/dist/models/Guild.js.map
index 580db503..e64d6c61 100644
--- a/dist/models/Guild.js.map
+++ b/dist/models/Guild.js.map
@@ -1 +1 @@
-{"version":3,"file":"Guild.js","sourceRoot":"","sources":["../../src/models/Guild.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA0D;AAC1D,gEAAkC;AAiDrB,QAAA,WAAW,GAAG,IAAI,iBAAM,CAAC;IACrC,EAAE,EAAE,EAAE,IAAI,EAAE,gBAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACxC,cAAc,EAAE,gBAAK,CAAC,IAAI;IAC1B,WAAW,EAAE,MAAM;IACnB,cAAc,EAAE,gBAAK,CAAC,IAAI;IAC1B,MAAM,EAAE,MAAM;IACd,6BAA6B,EAAE,MAAM;IACrC,WAAW,EAAE,MAAM;IACnB,gBAAgB,EAAE,MAAM;IACxB,uBAAuB,EAAE,MAAM;IAC/B,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACzC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;IAC9C,aAAa,EAAE,MAAM;IACrB,uBAAuB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;IACtD,YAAY,EAAE,MAAM;IACpB,cAAc,EAAE,MAAM;IACtB,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,QAAQ,EAA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,CAAC;AAEH,mBAAW,CAAC,OAAO,CAAC,UAAU,EAAE;IAC/B,GAAG,EAAE,sBAAY;IACjB,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,UAAU;IACxB,OAAO,EAAE,KAAK;CACd,CAAC,CAAC;AACH,mBAAW,CAAC,OAAO,CAAC,OAAO,EAAE;IAC5B,GAAG,EAAE,gBAAS;IACd,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,UAAU;IACxB,OAAO,EAAE,KAAK;CACd,CAAC,CAAC;AAEH,qFAAqF;AACrF,mBAAW,CAAC,OAAO,CAAC,SAAS,EAAE;IAC9B,GAAG,EAAE,oBAAW;IAChB,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,WAAW;IACzB,OAAO,EAAE,KAAK;CACd,CAAC,CAAC;AAEH,mBAAW,CAAC,OAAO,CAAC,QAAQ,EAAE;IAC7B,GAAG,EAAE,kBAAU;IACf,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,UAAU;IACxB,OAAO,EAAE,KAAK;CACd,CAAC,CAAC;AAEH,mBAAW,CAAC,OAAO,CAAC,WAAW,EAAE;IAChC,GAAG,EAAE,oBAAW;IAChB,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,UAAU;IACxB,OAAO,EAAE,IAAI;CACb,CAAC,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,OAAY,EAAE,GAAQ,EAAE,EAAE;IAC9C,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,SAAS,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,aAAa;AACA,QAAA,UAAU,GAAG,kBAAE,CAAC,KAAK,CAAgB,OAAO,EAAE,mBAAW,EAAE,QAAQ,CAAC,CAAC"}
\ No newline at end of file
diff --git a/dist/models/User.d.ts b/dist/models/User.d.ts
index adf6613f..2265c0a1 100644
--- a/dist/models/User.d.ts
+++ b/dist/models/User.d.ts
@@ -7,7 +7,6 @@ export interface User {
username: string;
discriminator: string;
avatar: string | null;
- fingerprints: string[];
phone?: string;
desktop: boolean;
mobile: boolean;
@@ -15,7 +14,6 @@ export interface User {
premium_type: number;
bot: boolean;
system: boolean;
- level: string;
nsfw_allowed: boolean;
mfa_enabled: boolean;
created_at: Date;
@@ -23,18 +21,22 @@ export interface User {
email?: string;
flags: bigint;
public_flags: bigint;
- hash: string;
- guilds: bigint[];
- valid_tokens_since: Date;
user_settings: UserSettings;
- relationships: Relationship[];
- connected_accounts: ConnectedAccount[];
+ user_data: UserData;
presence: {
status: Status;
activities: Activity[];
client_status: ClientStatus;
};
}
+export interface UserData {
+ valid_tokens_since: Date;
+ relationships: Relationship[];
+ connected_accounts: ConnectedAccount[];
+ guilds: bigint[];
+ hash: string;
+ fingerprints: string[];
+}
export interface UserDocument extends User, Document {
id: bigint;
}
diff --git a/dist/models/User.js b/dist/models/User.js
index e40df925..f6734de4 100644
--- a/dist/models/User.js
+++ b/dist/models/User.js
@@ -13,7 +13,6 @@ exports.UserSchema = new mongoose_1.Schema({
username: String,
discriminator: String,
avatar: String,
- fingerprints: [String],
phone: String,
desktop: Boolean,
mobile: Boolean,
@@ -28,9 +27,33 @@ exports.UserSchema = new mongoose_1.Schema({
email: String,
flags: mongoose_1.Types.Long,
public_flags: mongoose_1.Types.Long,
- hash: String,
- guilds: [mongoose_1.Types.Long],
- valid_tokens_since: Date,
+ user_data: {
+ fingerprints: [String],
+ hash: String,
+ guilds: [mongoose_1.Types.Long],
+ valid_tokens_since: Date,
+ relationships: [
+ {
+ id: mongoose_1.Types.Long,
+ nickname: String,
+ type: Number,
+ user_id: mongoose_1.Types.Long,
+ },
+ ],
+ connected_accounts: [
+ {
+ access_token: String,
+ friend_sync: Boolean,
+ id: String,
+ name: String,
+ revoked: Boolean,
+ show_activity: Boolean,
+ type: String,
+ verifie: Boolean,
+ visibility: Number,
+ },
+ ],
+ },
user_settings: {
afk_timeout: Number,
allow_accessibility_detection: Boolean,
@@ -77,27 +100,6 @@ exports.UserSchema = new mongoose_1.Schema({
theme: String,
timezone_offset: Number,
},
- relationships: [
- {
- id: mongoose_1.Types.Long,
- nickname: String,
- type: Number,
- user_id: mongoose_1.Types.Long,
- },
- ],
- connected_accounts: [
- {
- access_token: String,
- friend_sync: Boolean,
- id: String,
- name: String,
- revoked: Boolean,
- show_activity: Boolean,
- type: String,
- verifie: Boolean,
- visibility: Number,
- },
- ],
presence: {
status: String,
activities: [Activity_1.Activity],
diff --git a/dist/models/User.js.map b/dist/models/User.js.map
index 5d5e5b10..47442401 100644
--- a/dist/models/User.js.map
+++ b/dist/models/User.js.map
@@ -1 +1 @@
-{"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/models/User.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAsC;AACtC,qCAAgD;AAChD,uCAAmD;AACnD,gEAAkC;AAgHrB,QAAA,UAAU,GAAG,IAAI,iBAAM,CAAC;IACpC,EAAE,EAAE,gBAAK,CAAC,IAAI;IACd,QAAQ,EAAE,MAAM;IAChB,aAAa,EAAE,MAAM;IACrB,MAAM,EAAE,MAAM;IACd,YAAY,EAAE,CAAC,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,MAAM;IACpB,GAAG,EAAE,OAAO;IACZ,MAAM,EAAE,OAAO;IACf,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,gBAAK,CAAC,IAAI;IACjB,YAAY,EAAE,gBAAK,CAAC,IAAI;IACxB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,CAAC,gBAAK,CAAC,IAAI,CAAC;IACpB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE;QACd,WAAW,EAAE,MAAM;QACnB,6BA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,CAAC,IAAI;SACnB;KACD;IACD,kBAAkB,EAAE;QACnB;YACC,YAAY,EAAE,MAAM;YACpB,WAAW,EAAE,OAAO;YACpB,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;YAChB,aAAa,EAAE,OAAO;YACtB,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE,MAAM;SAClB;KACD;IACD,QAAQ,EAAE;QACT,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,CAAC,mBAAQ,CAAC;QACtB,aAAa,EAAE,qBAAY;KAC3B;CACD,CAAC,CAAC;AAEH,aAAa;AACA,QAAA,SAAS,GAAG,kBAAE,CAAC,KAAK,CAAe,MAAM,EAAE,kBAAU,EAAE,OAAO,CAAC,CAAC"}
\ No newline at end of file
+{"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/models/User.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAsC;AACtC,qCAAgD;AAChD,uCAAmD;AACnD,gEAAkC;AAoHrB,QAAA,UAAU,GAAG,IAAI,iBAAM,CAAC;IACpC,EAAE,EAAE,gBAAK,CAAC,IAAI;IACd,QAAQ,EAAE,MAAM;IAChB,aAAa,EAAE,MAAM;IACrB,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,MAAM;IACpB,GAAG,EAAE,OAAO;IACZ,MAAM,EAAE,OAAO;IACf,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,gBAAK,CAAC,IAAI;IACjB,YAAY,EAAE,gBAAK,CAAC,IAAI;IACxB,SAAS,EAAE;QACV,YAAY,EAAE,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,MA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;aACZ;SACD;QACD,eAAe,EAAE,CAAC,gBAAK,CAAC,IAAI,CAAC;QAC7B,uBAAuB,EAAE,OAAO;QAChC,kBAAkB,EAAE,OAAO;QAC3B,MAAM,EAAE,MAAM;QACd,uBAAuB,EAAE,OAAO;QAChC,gCAAgC,EAAE,OAAO;QACzC,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE,OAAO;QACzB,iBAAiB,EAAE,CAAC,gBAAK,CAAC,IAAI,CAAC;QAC/B,iBAAiB,EAAE,OAAO;QAC1B,MAAM,EAAE,MAAM;QACd,4BAA4B,EAAE,OAAO;QACrC,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,MAAM;KACvB;IAED,QAAQ,EAAE;QACT,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,CAAC,mBAAQ,CAAC;QACtB,aAAa,EAAE,qBAAY;KAC3B;CACD,CAAC,CAAC;AAEH,aAAa;AACA,QAAA,SAAS,GAAG,kBAAE,CAAC,KAAK,CAAe,MAAM,EAAE,kBAAU,EAAE,OAAO,CAAC,CAAC"}
\ No newline at end of file
diff --git a/dist/util/Database.d.ts b/dist/util/Database.d.ts
index dcb9bc90..766efaef 100644
--- a/dist/util/Database.d.ts
+++ b/dist/util/Database.d.ts
@@ -22,8 +22,8 @@ export declare class MongooseCache extends EventEmitter {
constructor(collection: Collection, pipeline: Array>, opts: {
onlyEvents: boolean;
});
- init(): Promise;
- convertResult(obj: any): any;
+ init: () => Promise;
+ convertResult: (obj: any) => any;
change: (doc: ChangeEvent) => boolean | Promise | undefined;
- destroy(): Promise | undefined;
+ destroy: () => Promise | undefined;
}
diff --git a/dist/util/Database.js b/dist/util/Database.js
index 01b1b57c..6f8d284d 100644
--- a/dist/util/Database.js
+++ b/dist/util/Database.js
@@ -17,58 +17,63 @@ class MongooseCache extends events_1.default {
this.collection = collection;
this.pipeline = pipeline;
this.opts = opts;
- this.change = (doc) => {
- // @ts-ignore
- if (doc.fullDocument) {
- // @ts-ignore
- if (!this.opts.onlyEvents)
- this.data = doc.fullDocument;
- }
- switch (doc.operationType) {
- case "dropDatabase":
- return this.destroy();
- case "drop":
- return this.destroy();
- case "delete":
- return this.emit("delete", doc.documentKey._id.toHexString());
- case "insert":
- return this.emit("insert", doc.fullDocument);
- case "update":
- case "replace":
- return this.emit("change", doc.fullDocument);
- case "invalidate":
- return this.destroy();
- default:
- return;
+ this.init = async () => {
+ this.stream = this.collection.watch(this.pipeline, { fullDocument: "updateLookup" });
+ this.stream.on("change", this.change);
+ this.stream.on("close", this.destroy);
+ this.stream.on("error", console.error);
+ if (!this.opts.onlyEvents) {
+ const arr = await this.collection.aggregate(this.pipeline).toArray();
+ this.data = arr.length ? arr[0] : arr;
}
};
- }
- async init() {
- this.stream = this.collection.watch(this.pipeline, { fullDocument: "updateLookup" });
- this.stream.on("change", this.change);
- this.stream.on("close", this.destroy);
- this.stream.on("error", console.error);
- if (!this.opts.onlyEvents) {
- const arr = await this.collection.aggregate(this.pipeline).toArray();
- this.data = arr.length ? arr[0] : arr;
- }
- }
- convertResult(obj) {
- if (obj instanceof mongodb_1.Long)
- return BigInt(obj.toString());
- if (typeof obj === "object") {
- Object.keys(obj).forEach((key) => {
- obj[key] = this.convertResult(obj[key]);
- });
- }
- return obj;
- }
- destroy() {
- this.stream.off("change", this.change);
- this.emit("close");
- if (this.stream.isClosed())
- return;
- return this.stream.close();
+ this.convertResult = (obj) => {
+ if (obj instanceof mongodb_1.Long)
+ return BigInt(obj.toString());
+ if (typeof obj === "object") {
+ Object.keys(obj).forEach((key) => {
+ obj[key] = this.convertResult(obj[key]);
+ });
+ }
+ return obj;
+ };
+ this.change = (doc) => {
+ try {
+ // @ts-ignore
+ if (doc.fullDocument) {
+ // @ts-ignore
+ if (!this.opts.onlyEvents)
+ this.data = doc.fullDocument;
+ }
+ switch (doc.operationType) {
+ case "dropDatabase":
+ return this.destroy();
+ case "drop":
+ return this.destroy();
+ case "delete":
+ return this.emit("delete", doc.documentKey._id.toHexString());
+ case "insert":
+ return this.emit("insert", doc.fullDocument);
+ case "update":
+ case "replace":
+ return this.emit("change", doc.fullDocument);
+ case "invalidate":
+ return this.destroy();
+ default:
+ return;
+ }
+ }
+ catch (error) {
+ this.emit("error", error);
+ }
+ };
+ this.destroy = () => {
+ this.stream?.off("change", this.change);
+ this.emit("close");
+ if (this.stream.isClosed())
+ return;
+ return this.stream.close();
+ };
}
}
exports.MongooseCache = MongooseCache;
diff --git a/dist/util/Database.js.map b/dist/util/Database.js.map
index 7dacb4cd..f31cb665 100644
--- a/dist/util/Database.js.map
+++ b/dist/util/Database.js.map
@@ -1 +1 @@
-{"version":3,"file":"Database.js","sourceRoot":"","sources":["../../src/util/Database.ts"],"names":[],"mappings":";;;;;;AAAA,yBAAuB;AACvB,wDAA4D;AAC5D,qCAA0D;AAC1D,oDAAkC;AAClC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,sEAAsE,CAAC;AAE5G,MAAM,UAAU,GAAG,kBAAQ,CAAC,gBAAgB,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAEvE,kBAA2B,UAAU,CAAC;AAStC,MAAa,aAAc,SAAQ,gBAAY;IAI9C,YACQ,UAAsB,EACtB,QAAwC,EACxC,IAEN;QAED,KAAK,EAAE,CAAC;QAND,eAAU,GAAV,UAAU,CAAY;QACtB,aAAQ,GAAR,QAAQ,CAAgC;QACxC,SAAI,GAAJ,IAAI,CAEV;QA6BF,WAAM,GAAG,CAAC,GAAgB,EAAE,EAAE;YAC7B,aAAa;YACb,IAAI,GAAG,CAAC,YAAY,EAAE;gBACrB,aAAa;gBACb,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU;oBAAE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC;aACxD;YAED,QAAQ,GAAG,CAAC,aAAa,EAAE;gBAC1B,KAAK,cAAc;oBAClB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;gBACvB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AC;IA/DF,CAAC;CAgED;AA5ED,sCA4EC"}
\ No newline at end of file
diff --git a/dist/util/Permissions.js b/dist/util/Permissions.js
index dfa2ea74..c170f3f9 100644
--- a/dist/util/Permissions.js
+++ b/dist/util/Permissions.js
@@ -96,7 +96,9 @@ async function getPermission(user_id, guild_id, channel_id, cache) {
member = await Member_1.MemberModel.findOne({ guild_id, id: user_id }, "roles").exec();
if (!member)
throw new Error("Member not found");
- var roles = await Role_1.RoleModel.find({ guild_id, id: { $in: member.roles } }).exec();
+ var roles = await Role_1.RoleModel.find({ guild_id, id: { $in: member.roles } })
+ .lean()
+ .exec();
if (channel_id) {
channel = await Channel_1.ChannelModel.findOne({ id: channel_id }, "permission_overwrites").exec();
}
diff --git a/dist/util/Permissions.js.map b/dist/util/Permissions.js.map
index 39a64586..14774970 100644
--- a/dist/util/Permissions.js.map
+++ b/dist/util/Permissions.js.map
@@ -1 +1 @@
-{"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../src/util/Permissions.ts"],"names":[],"mappings":";;;AAAA,8EAA8E;AAC9E,8DAA8D;AAC9D,6CAA+D;AAC/D,+CAAkE;AAElE,yCAAiD;AACjD,yCAAsC;AACtC,2CAA4D;AAqC5D,MAAM,wBAAwB,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,qEAAqE;AAEjH,MAAa,WAAY,SAAQ,mBAAQ;IA0CxC,GAAG,CAAC,UAAgC,EAAE,UAAU,GAAG,IAAI;QACtD,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5F,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,UAAgC,EAAE,UAAU,GAAG,IAAI;QACtD,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,KAAK,CAAC,G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,EAAE,qBAAqB;SAC1C;KACD,CAAC,CAAC;IAEH,OAAO,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC;AACpC,CAAC;AApCD,sCAoCC"}
\ No newline at end of file
diff --git a/src/util/Database.ts b/src/util/Database.ts
index 2304378c..f5269675 100644
--- a/src/util/Database.ts
+++ b/src/util/Database.ts
@@ -29,7 +29,7 @@ export class MongooseCache extends EventEmitter {
super();
}
- async init() {
+ init = async () => {
this.stream = this.collection.watch(this.pipeline, { fullDocument: "updateLookup" });
this.stream.on("change", this.change);
@@ -40,9 +40,9 @@ export class MongooseCache extends EventEmitter {
const arr = await this.collection.aggregate(this.pipeline).toArray();
this.data = arr.length ? arr[0] : arr;
}
- }
+ };
- convertResult(obj: any) {
+ convertResult = (obj: any) => {
if (obj instanceof Long) return BigInt(obj.toString());
if (typeof obj === "object") {
Object.keys(obj).forEach((key) => {
@@ -51,40 +51,44 @@ export class MongooseCache extends EventEmitter {
}
return obj;
- }
+ };
change = (doc: ChangeEvent) => {
- // @ts-ignore
- if (doc.fullDocument) {
+ try {
// @ts-ignore
- if (!this.opts.onlyEvents) this.data = doc.fullDocument;
- }
+ if (doc.fullDocument) {
+ // @ts-ignore
+ if (!this.opts.onlyEvents) this.data = doc.fullDocument;
+ }
- switch (doc.operationType) {
- case "dropDatabase":
- return this.destroy();
- case "drop":
- return this.destroy();
- case "delete":
- return this.emit("delete", doc.documentKey._id.toHexString());
- case "insert":
- return this.emit("insert", doc.fullDocument);
- case "update":
- case "replace":
- return this.emit("change", doc.fullDocument);
- case "invalidate":
- return this.destroy();
- default:
- return;
+ switch (doc.operationType) {
+ case "dropDatabase":
+ return this.destroy();
+ case "drop":
+ return this.destroy();
+ case "delete":
+ return this.emit("delete", doc.documentKey._id.toHexString());
+ case "insert":
+ return this.emit("insert", doc.fullDocument);
+ case "update":
+ case "replace":
+ return this.emit("change", doc.fullDocument);
+ case "invalidate":
+ return this.destroy();
+ default:
+ return;
+ }
+ } catch (error) {
+ this.emit("error", error);
}
};
- destroy() {
- this.stream.off("change", this.change);
+ destroy = () => {
+ this.stream?.off("change", this.change);
this.emit("close");
if (this.stream.isClosed()) return;
return this.stream.close();
- }
+ };
}
diff --git a/src/util/Permissions.ts b/src/util/Permissions.ts
index ae21e138..809111bf 100644
--- a/src/util/Permissions.ts
+++ b/src/util/Permissions.ts
@@ -158,7 +158,9 @@ export async function getPermission(
member = await MemberModel.findOne({ guild_id, id: user_id }, "roles").exec();
if (!member) throw new Error("Member not found");
- var roles = await RoleModel.find({ guild_id, id: { $in: member.roles } }).exec();
+ var roles = await RoleModel.find({ guild_id, id: { $in: member.roles } })
+ .lean()
+ .exec();
if (channel_id) {
channel = await ChannelModel.findOne({ id: channel_id }, "permission_overwrites").exec();
}