summary refs log tree commit diff
path: root/src/api/util
diff options
context:
space:
mode:
authorCyberL1 <cyber.hf18@gmail.com>2025-12-18 21:31:43 +0100
committerCyberL1 <cyber.hf18@gmail.com>2025-12-18 21:31:43 +0100
commit3b34a0bf6d0c1845ddaa44d1d68b71406f4a7e39 (patch)
treef1fdff653edd0e6514eb6a07abf823f15b65a6ba /src/api/util
parentFix identify trace (diff)
downloadserver-ts-3b34a0bf6d0c1845ddaa44d1d68b71406f4a7e39.tar.xz
feat: add message forwards (normal messages only)
Diffstat (limited to 'src/api/util')
-rw-r--r--src/api/util/handlers/Message.ts40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts

index 915fe292..84758c0b 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -232,7 +232,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { if (!opts.message_reference.guild_id) opts.message_reference.guild_id = channel.guild_id; if (!opts.message_reference.channel_id) opts.message_reference.channel_id = opts.channel_id; - if (!guild.features.includes("CROSS_CHANNEL_REPLIES")) { + if (opts.message_reference.type != 1) { if (opts.message_reference.guild_id !== channel.guild_id) throw new HTTPError("You can only reference messages from this guild"); if (opts.message_reference.channel_id !== opts.channel_id) throw new HTTPError("You can only reference messages from this channel"); } @@ -257,7 +257,16 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { } // TODO: stickers/activity - if (!allow_empty && !opts.content && !opts.embeds?.length && !opts.attachments?.length && !opts.sticker_ids?.length && !opts.poll && !opts.components?.length) { + if ( + !allow_empty && + !opts.content && + !opts.embeds?.length && + !opts.attachments?.length && + !opts.sticker_ids?.length && + !opts.poll && + !opts.components?.length && + opts.message_reference?.type != 1 + ) { console.log("[Message] Rejecting empty message:", opts, message); throw new HTTPError("Empty messages are not allowed", 50006); } @@ -314,6 +323,33 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { }), ); } + + // FORWARD + if (message.message_reference.type === 1) { + message.type = MessageType.DEFAULT; + + if (message.referenced_message) { + const mention_roles: string[] = []; + const mentions: string[] = []; + + message.message_snapshots = [ + { + message: { + attachments: message.referenced_message.attachments, + components: message.referenced_message.components, + content: message.referenced_message.content!, + edited_timestamp: message.referenced_message.edited_timestamp, + embeds: message.referenced_message.embeds, + flags: message.referenced_message.flags, + mention_roles, + mentions, + timestamp: message.referenced_message.timestamp, + type: message.referenced_message.type, + }, + }, + ]; + } + } } // root@Rory - 20/02/2023 - This breaks channel mentions in test client. We're not sure this was used in older clients.