From c6f5550c6e8350575a1fa4861dd73a4f41a60b41 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Thu, 11 Aug 2022 09:57:15 +0700 Subject: [PATCH] fix(ThreadChannel): Handle possibly `null` parent (v13) #8467 djs v13.10 --- 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 d642b9a..10afa20 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 ad7f0f1..1de5aae 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2852,7 +2852,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',