summary refs log tree commit diff
path: root/src/models/Member.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/Member.ts')
-rw-r--r--src/models/Member.ts47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/models/Member.ts b/src/models/Member.ts
index a38a5ca3..d9f34ac8 100644
--- a/src/models/Member.ts
+++ b/src/models/Member.ts
@@ -1,6 +1,7 @@
 import { PublicUser } from "./User";
+import { Schema, model, Types, Document } from "mongoose";
 
-export interface Member {
+export interface Member extends Document {
 	id: bigint;
 	nick?: string;
 	roles: bigint[];
@@ -13,10 +14,6 @@ export interface Member {
 	settings: UserGuildSettings;
 }
 
-export interface PublicMember extends Omit<Member, "settings" | "id"> {
-	user: PublicUser;
-}
-
 export interface UserGuildSettings {
 	channel_overrides: {
 		channel_id: bigint;
@@ -37,3 +34,43 @@ export interface MuteConfig {
 	end_time: number;
 	selected_time_window: number;
 }
+
+const MuteConfig = {
+	end_time: Number,
+	selected_time_window: Number,
+};
+
+export const MemberSchema = new Schema({
+	id: Types.Long,
+	nick: String,
+	roles: [Types.Long],
+	joined_at: Number,
+	premium_since: Number,
+	deaf: Boolean,
+	mute: Boolean,
+	pending: Boolean,
+	permissions: Types.Long,
+	settings: {
+		channel_overrides: [
+			{
+				channel_id: Types.Long,
+				message_notifications: Number,
+				mute_config: MuteConfig,
+				muted: Boolean,
+			},
+		],
+		message_notifications: Number,
+		mobile_push: Boolean,
+		mute_config: MuteConfig,
+		muted: Boolean,
+		suppress_everyone: Boolean,
+		suppress_roles: Boolean,
+		version: Number,
+	},
+});
+
+export const MemberModel = model<Member>("Member", MemberSchema, "members");
+
+export interface PublicMember extends Omit<Member, "settings" | "id"> {
+	user: PublicUser;
+}