Skip to content

Commit

Permalink
fix(ThreadChannel): Handle possibly null parent (#8466)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Aug 10, 2022
1 parent 4d72839 commit afa27b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/discord.js/src/structures/ThreadChannel.js
Expand Up @@ -283,10 +283,11 @@ class ThreadChannel extends BaseChannel {
* <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({ message: this.id, ...options });
// eslint-disable-next-line require-await
async fetchStarterMessage(options) {
return this.parent?.messages.fetch({ message: this.id, ...options }) ?? null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/typings/index.d.ts
Expand Up @@ -2540,7 +2540,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, ['fetchWeb
checkAdmin?: boolean,
): Readonly<PermissionsBitField> | 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<AnyThreadChannel>;
public setAutoArchiveDuration(
autoArchiveDuration: ThreadAutoArchiveDuration,
Expand Down

1 comment on commit afa27b1

@vercel
Copy link

@vercel vercel bot commented on afa27b1 Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.