From ba3e87e73c4954154bd737ebba0853181956f0f9 Mon Sep 17 00:00:00 2001 From: Nobody Date: Wed, 9 Mar 2022 06:04:50 -0300 Subject: fix(api): working replies in dm channels --- api/src/util/handlers/Message.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'api/src') diff --git a/api/src/util/handlers/Message.ts b/api/src/util/handlers/Message.ts index 21664368..2d9f7032 100644 --- a/api/src/util/handlers/Message.ts +++ b/api/src/util/handlers/Message.ts @@ -82,10 +82,12 @@ export async function handleMessage(opts: MessageOptions): Promise { if (opts.message_reference) { permission.hasThrow("READ_MESSAGE_HISTORY"); // code below has to be redone when we add custom message routing and cross-channel replies - const guild = await Guild.findOneOrFail({ id: channel.guild_id }); - if (!guild.features.includes("CROSS_CHANNEL_REPLIES")) { - 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"); + if (message.guild_id !== null) { + const guild = await Guild.findOneOrFail({ id: channel.guild_id }); + if (!guild.features.includes("CROSS_CHANNEL_REPLIES")) { + 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"); + } } // TODO: should be checked if the referenced message exists? // @ts-ignore -- cgit 1.5.1