fix(ThreadChannel): Handle possibly null parent (v13)

#8467 djs v13.10
This commit is contained in:
March 7th 2022-08-11 09:57:15 +07:00
parent 19fc481496
commit c6f5550c6e
2 changed files with 5 additions and 4 deletions

View File

@ -283,10 +283,11 @@ class ThreadChannel extends Channel {
* <info>This only works when the thread started from a message in the parent channel, otherwise the promise will * <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> * reject. If you just need the id of that message, use {@link ThreadChannel#id} instead.</info>
* @param {BaseFetchOptions} [options] Additional options for this fetch * @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<Message>} * @returns {Promise<Message|null>}
*/ */
fetchStarterMessage(options) { // eslint-disable-next-line require-await
return this.parent.messages.fetch(this.id, options); async fetchStarterMessage(options) {
return this.parent?.messages.fetch(this.id, options) ?? null;
} }
/** /**

2
typings/index.d.ts vendored
View File

@ -2852,7 +2852,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhook
checkAdmin?: boolean, checkAdmin?: boolean,
): Readonly<Permissions> | null; ): Readonly<Permissions> | null;
public fetchOwner(options?: BaseFetchOptions): Promise<ThreadMember | null>; public fetchOwner(options?: BaseFetchOptions): Promise<ThreadMember | null>;
public fetchStarterMessage(options?: BaseFetchOptions): Promise<Message>; public fetchStarterMessage(options?: BaseFetchOptions): Promise<Message | null>;
public setArchived(archived?: boolean, reason?: string): Promise<ThreadChannel>; public setArchived(archived?: boolean, reason?: string): Promise<ThreadChannel>;
public setAutoArchiveDuration( public setAutoArchiveDuration(
autoArchiveDuration: ThreadAutoArchiveDuration | 'MAX', autoArchiveDuration: ThreadAutoArchiveDuration | 'MAX',