From 8995bf4ba484a6037d606d4930e39e2e73b697a5 Mon Sep 17 00:00:00 2001
From: Jiralite <33201955+Jiralite@users.noreply.github.com>
Date: Mon, 19 Sep 2022 14:40:01 +0100
Subject: [PATCH] fix(ThreadChannel): make `fetchStarterMessage()` work in
forum posts
---
packages/discord.js/src/structures/ThreadChannel.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js
index fc365c17dc43..3c646b368925 100644
--- a/packages/discord.js/src/structures/ThreadChannel.js
+++ b/packages/discord.js/src/structures/ThreadChannel.js
@@ -301,14 +301,16 @@ class ThreadChannel extends BaseChannel {
/**
* Fetches the message that started this thread, if any.
- * This only works when the thread started from a message in the parent channel, otherwise the promise will
- * reject. If you just need the id of that message, use {@link ThreadChannel#id} instead.
+ * The `Promise` will reject if the original message in a forum post is deleted
+ * or when the original message in the parent channel is deleted.
+ * If you just need the id of that message, use {@link ThreadChannel#id} instead.
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise|null>}
*/
// eslint-disable-next-line require-await
async fetchStarterMessage(options) {
- return this.parent?.messages.fetch({ message: this.id, ...options }) ?? null;
+ const channel = this.parent?.type === ChannelType.GuildForum ? this : this.parent;
+ return channel?.messages.fetch({ message: this.id, ...options }) ?? null;
}
/**