mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
fix(ThreadChannel): Handle possibly null parent (#8466)
This commit is contained in:
@@ -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
|
* <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({ message: this.id, ...options });
|
async fetchStarterMessage(options) {
|
||||||
|
return this.parent?.messages.fetch({ message: this.id, ...options }) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -2540,7 +2540,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, ['fetchWeb
|
|||||||
checkAdmin?: boolean,
|
checkAdmin?: boolean,
|
||||||
): Readonly<PermissionsBitField> | null;
|
): Readonly<PermissionsBitField> | 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<AnyThreadChannel>;
|
public setArchived(archived?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setAutoArchiveDuration(
|
public setAutoArchiveDuration(
|
||||||
autoArchiveDuration: ThreadAutoArchiveDuration,
|
autoArchiveDuration: ThreadAutoArchiveDuration,
|
||||||
|
|||||||
Reference in New Issue
Block a user