summary refs log tree commit diff
diff options
context:
space:
mode:
authorNobody <git@n0bodysec.com>2022-03-09 06:04:50 -0300
committerErkin Alp Güney <erkinalp9035@gmail.com>2022-03-09 17:09:36 +0300
commit64f0b1f1a16c89c7f47facf2d0a73400e377cbe2 (patch)
tree1f39d6398b4d48e2481ac0cafa90ed6d8bc64cdc
parentMerge pull request #675 from nobodylabs/fix/ban-list (diff)
downloadserver-64f0b1f1a16c89c7f47facf2d0a73400e377cbe2.tar.xz
fix(api): working replies in dm channels
-rw-r--r--api/src/util/handlers/Message.ts10
1 files changed, 6 insertions, 4 deletions
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<Message> {
 	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