From 2a46d9f58e4714c8580218a3459992bbfec2bcf7 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Wed, 10 Aug 2022 19:17:21 +0100 Subject: [PATCH] fix(ThreadChannel): Handle possibly `null` parent (v13) (#8467) --- src/structures/ThreadChannel.js | 7 ++++--- typings/index.d.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/structures/ThreadChannel.js b/src/structures/ThreadChannel.js index d642b9ac138f..10afa20e6888 100644 --- a/src/structures/ThreadChannel.js +++ b/src/structures/ThreadChannel.js @@ -283,10 +283,11 @@ class ThreadChannel extends Channel { * 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(this.id, options); + // eslint-disable-next-line require-await + async fetchStarterMessage(options) { + return this.parent?.messages.fetch(this.id, options) ?? null; } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index d67f2fd44250..681fd296982b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2518,7 +2518,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhook 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 | 'MAX',