Skip to content

Commit

Permalink
fix(ThreadChannel): Handle possibly null parent (v13) (#8467)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Aug 10, 2022
1 parent 78e494b commit 2a46d9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/structures/ThreadChannel.js
Expand Up @@ -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
* reject. 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>}
* @returns {Promise<Message|null>}
*/
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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Expand Up @@ -2518,7 +2518,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhook
checkAdmin?: boolean,
): Readonly<Permissions> | 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 setAutoArchiveDuration(
autoArchiveDuration: ThreadAutoArchiveDuration | 'MAX',
Expand Down

0 comments on commit 2a46d9f

Please sign in to comment.