From 59ea91625bbc7f661ff55f38fd33d69500a17799 Mon Sep 17 00:00:00 2001
From: Jiralite <33201955+Jiralite@users.noreply.github.com>
Date: Wed, 10 Aug 2022 18:59:40 +0100
Subject: [PATCH] fix(ThreadChannel): handle possibly `null` parent
---
packages/discord.js/src/structures/ThreadChannel.js | 7 ++++---
packages/discord.js/typings/index.d.ts | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js
index fe757c62d715..14cbe6b84dd9 100644
--- a/packages/discord.js/src/structures/ThreadChannel.js
+++ b/packages/discord.js/src/structures/ThreadChannel.js
@@ -283,10 +283,11 @@ class ThreadChannel extends BaseChannel {
* 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.
* @param {BaseFetchOptions} [options] Additional options for this fetch
- * @returns {Promise}
+ * @returns {Promise}
*/
- fetchStarterMessage(options) {
- return this.parent.messages.fetch({ message: this.id, ...options });
+ // eslint-disable-next-line require-await
+ async fetchStarterMessage(options) {
+ return this.parent?.messages.fetch({ message: this.id, ...options }) ?? null;
}
/**
diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts
index 84550ceae20f..f86f7c5182ee 100644
--- a/packages/discord.js/typings/index.d.ts
+++ b/packages/discord.js/typings/index.d.ts
@@ -2540,7 +2540,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, ['fetchWeb
checkAdmin?: boolean,
): Readonly | null;
public fetchOwner(options?: BaseFetchOptions): Promise;
- public fetchStarterMessage(options?: BaseFetchOptions): Promise;
+ public fetchStarterMessage(options?: BaseFetchOptions): Promise;
public setArchived(archived?: boolean, reason?: string): Promise;
public setAutoArchiveDuration(
autoArchiveDuration: ThreadAutoArchiveDuration,