summary refs log tree commit diff
path: root/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/AuditLog.ts2
-rw-r--r--src/models/Guild.ts2
-rw-r--r--src/models/Member.ts2
-rw-r--r--src/models/Message.ts77
-rw-r--r--src/models/User.ts4
5 files changed, 62 insertions, 25 deletions
diff --git a/src/models/AuditLog.ts b/src/models/AuditLog.ts

index f69c4329..a0f91a82 100644 --- a/src/models/AuditLog.ts +++ b/src/models/AuditLog.ts
@@ -7,7 +7,7 @@ export interface AuditLogResponse { webhooks: []; // TODO: users: PublicUser[]; audit_log_entries: AuditLogEntries[]; - integrations: []; + integrations: []; // TODO: } export interface AuditLogEntries { diff --git a/src/models/Guild.ts b/src/models/Guild.ts
index effc20ee..b25be7aa 100644 --- a/src/models/Guild.ts +++ b/src/models/Guild.ts
@@ -49,6 +49,7 @@ export interface Guild { } export const GuildSchema = new Schema({ + id: { type: Types.Long, required: true }, afk_channel_id: Types.Long, afk_timeout: Number, application_id: Types.Long, @@ -59,7 +60,6 @@ export const GuildSchema = new Schema({ explicit_content_filter: Number, features: { type: [String], default: [] }, icon: String, - id: { type: Types.Long, required: true }, large: Boolean, max_members: { type: Number, default: 100000 }, max_presences: Number, diff --git a/src/models/Member.ts b/src/models/Member.ts
index 5e0e0014..97ed1961 100644 --- a/src/models/Member.ts +++ b/src/models/Member.ts
@@ -75,7 +75,7 @@ export const MemberSchema = new Schema({ }, }); -exports.MemberSchema.virtual("user", { +MemberSchema.virtual("user", { ref: UserModel, localField: "id", foreignField: "id", diff --git a/src/models/Message.ts b/src/models/Message.ts
index 6353c588..43517313 100644 --- a/src/models/Message.ts +++ b/src/models/Message.ts
@@ -1,10 +1,13 @@ -import { Schema, model, Types, Document } from "mongoose"; -import { ChannelType } from "./Channel"; +import { Schema, Types, Document } from "mongoose"; import db from "../util/Database"; +import { UserModel } from "./User"; +import { MemberModel } from "./Member"; +import { RoleModel } from "./Role"; export interface Message extends Document { id: bigint; channel_id: bigint; + guild_id?: bigint; author_id?: bigint; webhook_id?: bigint; application_id: bigint; @@ -13,14 +16,9 @@ export interface Message extends Document { edited_timestamp: number; tts: boolean; mention_everyone: boolean; - mentions: bigint[]; - mention_roles: bigint[]; - mention_channels?: { - id: bigint; - guild_id: bigint; - type: ChannelType; - name: string; - }[]; + mention_user_ids: bigint[]; + mention_role_ids: bigint[]; + mention_channels_ids: bigint[]; attachments: Attachment[]; embeds: Embed[]; reactions?: Reaction[]; @@ -154,7 +152,7 @@ const Reaction = { }, }; -const Embed = { +export const Embed = { title: String, //title of embed type: String, // type of embed (always "rich" for webhook embeds) description: String, // description of embed @@ -193,22 +191,16 @@ export const MessageSchema = new Schema({ channel_id: Types.Long, author_id: Types.Long, webhook_id: Types.Long, + guild_id: Types.Long, application_id: Types.Long, content: String, timestamp: Number, edited_timestamp: Number, tts: Boolean, mention_everyone: Boolean, - mentions: [Types.Long], - mention_roles: [Types.Long], - mention_channels: [ - { - id: Types.Long, - guild_id: Types.Long, - type: { type: Number }, - name: String, - }, - ], + mention_user_ids: [Types.Long], + mention_role_ids: [Types.Long], + mention_channel_ids: [Types.Long], attachments: [Attachment], embeds: [Embed], reactions: [Reaction], @@ -228,5 +220,48 @@ export const MessageSchema = new Schema({ }, }); +MessageSchema.virtual("author", { + ref: UserModel, + localField: "author_id", + foreignField: "id", + justOne: true, +}); + +MessageSchema.virtual("member", { + ref: MemberModel, + localField: "author_id", + foreignField: "id", + justOne: true, +}); + +MessageSchema.virtual("mentions", { + ref: UserModel, + localField: "mention_user_ids", + foreignField: "id", + justOne: true, +}); + +MessageSchema.virtual("mention_roles", { + ref: RoleModel, + localField: "mention_role_ids", + foreignField: "id", + justOne: true, +}); + +MessageSchema.virtual("mention_channels", { + ref: RoleModel, + localField: "mention_role_ids", + foreignField: "id", + justOne: true, +}); + +// TODO: missing Application Model +// MessageSchema.virtual("application", { +// ref: Application, +// localField: "mention_role_ids", +// foreignField: "id", +// justOne: true, +// }); + // @ts-ignore export const MessageModel = db.model<Message>("Message", MessageSchema, "messages"); diff --git a/src/models/User.ts b/src/models/User.ts
index 00b7f8c6..66849844 100644 --- a/src/models/User.ts +++ b/src/models/User.ts
@@ -21,7 +21,7 @@ export interface User { 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 + email?: string; // email of the user flags: bigint; // UserFlags public_flags: bigint; hash: string; // hash of the password, salt is saved in password (bcrypt) @@ -88,6 +88,7 @@ export interface UserSettings { enable_tts_command: boolean; explicit_content_filter: number; friend_source_flags: { all: boolean }; + gateway_connected: boolean; gif_auto_play: boolean; guild_folders: // every top guild is displayed as a "folder" { @@ -155,6 +156,7 @@ export const UserSchema = new Schema({ enable_tts_command: Boolean, explicit_content_filter: Number, friend_source_flags: { all: Boolean }, + gateway_connected: Boolean, gif_auto_play: Boolean, // every top guild is displayed as a "folder" guild_folders: [