summary refs log tree commit diff
path: root/src/util/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/entities')
-rw-r--r--src/util/entities/Member.ts5
-rw-r--r--src/util/entities/Message.ts14
2 files changed, 15 insertions, 4 deletions
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts

index f372277e..00ac3a35 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts
@@ -442,12 +442,13 @@ export class Member extends BaseClassWithoutId { channel.last_message_id = message.id; + await message.save(); + const publicMsg = message.toJSON(); await Promise.all([ - message.save(), emitEvent({ event: "MESSAGE_CREATE", channel_id: message.channel_id, - data: message, + data: publicMsg, } satisfies MessageCreateEvent), channel.save(), ]); diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts
index 9649447c..b343a0cc 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts
@@ -36,6 +36,7 @@ import { MessageComponentType, MessageSnapshot, MessageType, PartialMessage, Poll, PublicMessage, Reaction, UnfurledMediaItem, } from "@spacebar/schemas"; +import { PartialUser } from "@spacebar/schemas"; import { MessageFlags } from "@spacebar/util"; import { JsonRemoveEmpty } from "../util/Decorators"; @@ -251,15 +252,23 @@ export class Message extends BaseClass { ...this, channel_id: this.channel_id ?? this.channel.id, channel: undefined, + + timestamp: this.timestamp.toISOString(), + edited_timestamp: this.edited_timestamp ? this.edited_timestamp.toISOString() : null, + author_id: undefined, member_id: undefined, webhook_id: this.webhook_id ?? undefined, application_id: undefined, mentions: this.mentions?.map((user) => { if (user && !user.toPublicUser) console.trace("toPublic user missing!!!"); - return user?.toPublicUser?.() ?? user ?? undefined; + return (user?.toPublicUser?.() ?? user ?? undefined) as unknown as PartialUser; }), + mention_roles: this.mention_roles?.map((role) => role.id) ?? [], + mention_channels: this.mention_channels?.map((ch) => ch.toJSON()) ?? [], + attachments: this.attachments ?? [], + nonce: this.nonce ?? undefined, tts: this.tts ?? false, guild: this.guild ?? undefined, @@ -269,6 +278,7 @@ export class Message extends BaseClass { reactions: this.reactions ?? undefined, sticker_items: this.sticker_items ?? undefined, message_reference: this.message_reference ?? undefined, + mention_everyone: this.mention_everyone ?? false, author: { ...(this.author?.toPublicUser() ?? undefined), // Webhooks @@ -277,7 +287,7 @@ export class Message extends BaseClass { }, activity: this.activity ?? undefined, application: this.application ?? undefined, - components: this.components ?? undefined, + components: this.components ?? [], poll: this.poll ?? undefined, content: this.content ?? "", pinned: this.pinned,