Skip to content

Commit 2a46d9f

Browse files
authored
fix(ThreadChannel): Handle possibly null parent (v13) (#8467)
1 parent 78e494b commit 2a46d9f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/structures/ThreadChannel.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,11 @@ class ThreadChannel extends Channel {
283283
* <info>This only works when the thread started from a message in the parent channel, otherwise the promise will
284284
* reject. If you just need the id of that message, use {@link ThreadChannel#id} instead.</info>
285285
* @param {BaseFetchOptions} [options] Additional options for this fetch
286-
* @returns {Promise<Message>}
286+
* @returns {Promise<Message|null>}
287287
*/
288-
fetchStarterMessage(options) {
289-
return this.parent.messages.fetch(this.id, options);
288+
// eslint-disable-next-line require-await
289+
async fetchStarterMessage(options) {
290+
return this.parent?.messages.fetch(this.id, options) ?? null;
290291
}
291292

292293
/**

typings/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhook
25182518
checkAdmin?: boolean,
25192519
): Readonly<Permissions> | null;
25202520
public fetchOwner(options?: BaseFetchOptions): Promise<ThreadMember | null>;
2521-
public fetchStarterMessage(options?: BaseFetchOptions): Promise<Message>;
2521+
public fetchStarterMessage(options?: BaseFetchOptions): Promise<Message | null>;
25222522
public setArchived(archived?: boolean, reason?: string): Promise<ThreadChannel>;
25232523
public setAutoArchiveDuration(
25242524
autoArchiveDuration: ThreadAutoArchiveDuration | 'MAX',

0 commit comments

Comments
 (0)