Fix Member Model

This commit is contained in:
Flam3rboy 2021-02-22 17:34:09 +01:00
parent c058020a7c
commit dae8843ccb
3 changed files with 27 additions and 24 deletions

View File

@ -14,7 +14,7 @@ export interface Emoji extends Document {
} }
export const EmojiSchema = new Schema({ export const EmojiSchema = new Schema({
id: Types.Long, id: { type: Types.Long, required: true },
animated: Boolean, animated: Boolean,
available: Boolean, available: Boolean,
guild_id: Types.Long, guild_id: Types.Long,

View File

@ -12,7 +12,6 @@ export interface Member {
deaf: boolean; deaf: boolean;
mute: boolean; mute: boolean;
pending: boolean; pending: boolean;
permissions: bigint;
settings: UserGuildSettings; settings: UserGuildSettings;
} }
@ -56,7 +55,6 @@ export const MemberSchema = new Schema({
deaf: Boolean, deaf: Boolean,
mute: Boolean, mute: Boolean,
pending: Boolean, pending: Boolean,
permissions: Types.Long,
settings: { settings: {
channel_overrides: [ channel_overrides: [
{ {

View File

@ -1,27 +1,28 @@
import { Activity } from "./Activity"; import { Activity } from "./Activity";
import { ClientStatus, Status } from "./Status"; import { ClientStatus, Status } from "./Status";
import { Schema, model, Types, Document } from "mongoose"; import { Schema, Types, Document } from "mongoose";
import db from "../util/Database"; import db from "../util/Database";
export interface User extends Document { export interface User {
id: bigint; id: bigint;
username: string; username: string; // username max length 32, min 2
discriminator: string; discriminator: string; // #0001 4 digit long string from #0001 - #9999
avatar: string | null; avatar: string | null; // hash of the user avatar
fingerprints: string[]; fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts
phone?: string; phone?: string; // phone number of the user
desktop: boolean; desktop: boolean; // if the user has desktop app installed
mobile: boolean; mobile: boolean; // if the user has mobile app installed
premium: boolean; premium: boolean; // if user bought nitro
premium_type: number; premium_type: number; // nitro level
bot: boolean; bot: boolean; // if user is bot
system: boolean; system: boolean; // shouldn't be used, the api sents this field type true, if the genetaed message comes from a system generated author
nsfw_allowed: boolean; level: string; // organization permission level (owner, moderator, user)
mfa_enabled: boolean; nsfw_allowed: boolean; // if the user is older than 18 (resp. Config)
created_at: number; mfa_enabled: boolean; // if multi factor authentication is enabled
verified: boolean; created_at: number; // registration date
email: string; verified: boolean; // if the user is offically verified
flags: bigint; // TODO: automatically convert BigInt to BitField of UserFlags email: string; // email of the user
flags: bigint; // UserFlags
public_flags: bigint; public_flags: bigint;
hash: string; // hash of the password, salt is saved in password (bcrypt) hash: string; // hash of the password, salt is saved in password (bcrypt)
guilds: bigint[]; // array of guild ids the user is part of 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 { export interface PublicUser {
id: bigint; id: bigint;
discriminator: string; discriminator: string;
username: string; username: string;
avatar?: string; avatar?: string;
publicFlags: bigint; public_flags: bigint;
} }
export interface ConnectedAccount { export interface ConnectedAccount {
@ -204,4 +209,4 @@ export const UserSchema = new Schema({
}); });
// @ts-ignore // @ts-ignore
export const UserModel = db.model<User>("User", UserSchema, "users"); export const UserModel = db.model<UserDocument>("User", UserSchema, "users");