summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-03-11 00:54:47 +0100
committerRory& <root@rory.gay>2026-03-21 08:21:30 +0100
commit46176e9ebf1cf1ced6c032797e4e0cdec0390213 (patch)
treed6ea450f719f878cb8c7b6ae24ab1573e8ed455b
parentMessage*Event: as->satisfies (WIP) (diff)
downloadserver-ts-46176e9ebf1cf1ced6c032797e4e0cdec0390213.tar.xz
Message toJSON -> null vs undefined
-rw-r--r--src/util/entities/Message.ts14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts

index 735402f2..9649447c 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts
@@ -33,12 +33,7 @@ import { ApplicationCommandType, BaseMessageComponents, Embed, - MessageComponentType, - MessageSnapshot, - MessageType, - PartialMessage, - Poll, - Reaction, + MessageComponentType, MessageSnapshot, MessageType, PartialMessage, Poll, PublicMessage, Reaction, UnfurledMediaItem, } from "@spacebar/schemas"; import { MessageFlags } from "@spacebar/util"; @@ -251,9 +246,10 @@ export class Message extends BaseClass { } } - toJSON(shallow = false): Message { + toJSON(shallow = false): PublicMessage { return { ...this, + channel_id: this.channel_id ?? this.channel.id, channel: undefined, author_id: undefined, member_id: undefined, @@ -276,8 +272,8 @@ export class Message extends BaseClass { author: { ...(this.author?.toPublicUser() ?? undefined), // Webhooks - username: this.username ?? this.author?.username, - avatar: this.avatar ?? this.author?.avatar, + username: this.username ?? this.author?.username ?? null, + avatar: this.avatar ?? this.author?.avatar ?? null, }, activity: this.activity ?? undefined, application: this.application ?? undefined,