1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-22 02:31:36 +02:00

Message reply

This commit is contained in:
Flam3rboy 2021-06-24 08:52:08 +02:00
parent 9b3f1f5a64
commit ae1fc50c84

View File

@ -342,6 +342,15 @@ MessageSchema.virtual("mention_channels", {
autopopulate: { select: { id: true, guild_id: true, type: true, name: true } },
});
MessageSchema.virtual("referenced_message", {
ref: "Message",
localField: "message_reference.message_id",
foreignField: "id",
justOne: true,
autopopulate: true,
});
MessageSchema.virtual("created_at").get(function (this: MessageDocument) {
return new Date(Snowflake.deconstruct(this.id).timestamp);
});
@ -358,3 +367,4 @@ MessageSchema.set("removeResponse", ["mention_channel_ids", "mention_role_ids",
// @ts-ignore
export const MessageModel = db.model<MessageDocument>("Message", MessageSchema, "messages");