From dae8843ccbb2f72981fc273b56576f6b8e8fd3b0 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 22 Feb 2021 17:34:09 +0100 Subject: [PATCH] Fix Member Model --- src/models/Emoji.ts | 2 +- src/models/Member.ts | 2 -- src/models/User.ts | 47 ++++++++++++++++++++++++-------------------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/models/Emoji.ts b/src/models/Emoji.ts index 298737e5..530c2cc7 100644 --- a/src/models/Emoji.ts +++ b/src/models/Emoji.ts @@ -14,7 +14,7 @@ export interface Emoji extends Document { } export const EmojiSchema = new Schema({ - id: Types.Long, + id: { type: Types.Long, required: true }, animated: Boolean, available: Boolean, guild_id: Types.Long, diff --git a/src/models/Member.ts b/src/models/Member.ts index 422a83cf..a377f54e 100644 --- a/src/models/Member.ts +++ b/src/models/Member.ts @@ -12,7 +12,6 @@ export interface Member { deaf: boolean; mute: boolean; pending: boolean; - permissions: bigint; settings: UserGuildSettings; } @@ -56,7 +55,6 @@ export const MemberSchema = new Schema({ deaf: Boolean, mute: Boolean, pending: Boolean, - permissions: Types.Long, settings: { channel_overrides: [ { diff --git a/src/models/User.ts b/src/models/User.ts index 5dfe320c..00b7f8c6 100644 --- a/src/models/User.ts +++ b/src/models/User.ts @@ -1,27 +1,28 @@ import { Activity } from "./Activity"; import { ClientStatus, Status } from "./Status"; -import { Schema, model, Types, Document } from "mongoose"; +import { Schema, Types, Document } from "mongoose"; import db from "../util/Database"; -export interface User extends Document { +export interface User { id: bigint; - username: string; - discriminator: string; - avatar: string | null; - fingerprints: string[]; - phone?: string; - desktop: boolean; - mobile: boolean; - premium: boolean; - premium_type: number; - bot: boolean; - system: boolean; - nsfw_allowed: boolean; - mfa_enabled: boolean; - created_at: number; - verified: boolean; - email: string; - flags: bigint; // TODO: automatically convert BigInt to BitField of UserFlags + username: string; // username max length 32, min 2 + discriminator: string; // #0001 4 digit long string from #0001 - #9999 + avatar: string | null; // hash of the user avatar + fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts + phone?: string; // phone number of the user + desktop: boolean; // if the user has desktop app installed + mobile: boolean; // if the user has mobile app installed + premium: boolean; // if user bought nitro + premium_type: number; // nitro level + bot: boolean; // if user is bot + system: boolean; // shouldn't be used, the api sents this field type true, if the genetaed message comes from a system generated author + level: string; // organization permission level (owner, moderator, user) + nsfw_allowed: boolean; // if the user is older than 18 (resp. Config) + mfa_enabled: boolean; // if multi factor authentication is enabled + created_at: number; // registration date + verified: boolean; // if the user is offically verified + email: string; // email of the user + flags: bigint; // UserFlags public_flags: bigint; hash: string; // hash of the password, salt is saved in password (bcrypt) guilds: bigint[]; // array of guild ids the user is part of @@ -36,12 +37,16 @@ export interface User extends Document { }; } +export interface UserDocument extends User, Document { + id: bigint; +} + export interface PublicUser { id: bigint; discriminator: string; username: string; avatar?: string; - publicFlags: bigint; + public_flags: bigint; } export interface ConnectedAccount { @@ -204,4 +209,4 @@ export const UserSchema = new Schema({ }); // @ts-ignore -export const UserModel = db.model("User", UserSchema, "users"); +export const UserModel = db.model("User", UserSchema, "users");