Skip to content

Commit

Permalink
fix(ThreadChannel): Make fetchStarterMessage() work in forum posts (#…
Browse files Browse the repository at this point in the history
…8638)

fix(ThreadChannel): make `fetchStarterMessage()` work in forum posts

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] committed Sep 19, 2022
1 parent 802b239 commit a7f816e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/discord.js/src/structures/ThreadChannel.js
Expand Up @@ -301,14 +301,16 @@ class ThreadChannel extends BaseChannel {

/**
* Fetches the message that started this thread, if any.
* <info>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.</info>
* <info>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.</info>
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<Message<true>|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;
}

/**
Expand Down

0 comments on commit a7f816e

Please sign in to comment.