summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-26 22:38:05 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-26 22:38:05 +0200
commit29400f9d4dc998819a46c4faa7d92ac53492306d (patch)
treee2d49c7f71a4819c3785a60ba4cb93c01e668f88 /src
parent1.3.5 (diff)
downloadserver-29400f9d4dc998819a46c4faa7d92ac53492306d.tar.xz
:sparkles: add MessageComponent
Diffstat (limited to 'src')
-rw-r--r--src/models/Message.ts50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/models/Message.ts b/src/models/Message.ts
index 77d67a9a..3f2b85e6 100644
--- a/src/models/Message.ts
+++ b/src/models/Message.ts
@@ -5,6 +5,7 @@ import { MemberModel, PublicMember } from "./Member";
 import { Role, RoleModel } from "./Role";
 import { Channel } from "./Channel";
 import { Snowflake } from "../util";
+import { InteractionType } from "./Interaction";
 
 export interface Message {
 	id: string;
@@ -38,7 +39,18 @@ export interface Message {
 		channel_id?: string;
 		guild_id?: string;
 	};
-	// mongoose virtuals:
+	interaction?: {
+		id: string;
+		type: InteractionType;
+		name: string;
+		user_id: string; // the user who invoked the interaction
+		// user: User; // TODO: autopopulate user
+	};
+	components: MessageComponent[];
+
+	// * mongoose virtuals:
+	// TODO:
+	// application: Application; // TODO: auto pouplate application
 	author?: PublicUser;
 	member?: PublicMember;
 	mentions?: (PublicUser & {
@@ -47,6 +59,41 @@ export interface Message {
 	mention_roles?: Role[];
 	mention_channels?: Channel[];
 	created_at?: Date;
+	// thread // TODO
+}
+
+const PartialEmoji = {
+	id: String,
+	name: { type: String, required: true },
+	animated: { type: Boolean, required: true },
+};
+
+const MessageComponent: any = {
+	type: { type: Number, required: true },
+	style: Number,
+	label: String,
+	emoji: PartialEmoji,
+	custom_id: String,
+	url: String,
+	disabled: Boolean,
+};
+
+MessageComponent.components = [MessageComponent];
+
+export interface MessageComponent {
+	type: number;
+	style?: number;
+	label?: string;
+	emoji?: PartialEmoji;
+	custom_id?: string;
+	url?: string;
+	disabled?: boolean;
+	components: MessageComponent[];
+}
+
+export enum MessageComponentType {
+	ActionRow = 1,
+	Button = 2,
 }
 
 export interface MessageDocument extends Document, Message {
@@ -235,6 +282,7 @@ export const MessageSchema = new Schema({
 		channel_id: String,
 		guild_id: String,
 	},
+	components: [MessageComponent],
 	// virtual:
 	// author: {
 	// 	ref: UserModel,