Skip to content

Commit

Permalink
types: Narrow channel type in thread managers (#8640)
Browse files Browse the repository at this point in the history
types: narrow channel type in thread managers

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] committed Sep 19, 2022
1 parent a7f816e commit 14bbc91
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/discord.js/src/managers/GuildForumThreadManager.js
Expand Up @@ -10,6 +10,12 @@ const MessagePayload = require('../structures/MessagePayload');
* @extends {ThreadManager}
*/
class GuildForumThreadManager extends ThreadManager {
/**
* The channel this Manager belongs to
* @name GuildForumThreadManager#channel
* @type {ForumChannel}
*/

/**
* @typedef {BaseMessageOptions} GuildForumThreadCreateOptions
* @property {stickers} [stickers] The stickers to send with the message
Expand Down
6 changes: 6 additions & 0 deletions packages/discord.js/src/managers/GuildTextThreadManager.js
Expand Up @@ -9,6 +9,12 @@ const { ErrorCodes, TypeError } = require('../errors');
* @extends {ThreadManager}
*/
class GuildTextThreadManager extends ThreadManager {
/**
* The channel this Manager belongs to
* @name GuildTextThreadManager#channel
* @type {TextChannel|NewsChannel}
*/

/**
* Options for creating a thread. <warn>Only one of `startMessage` or `type` can be defined.</warn>
* @typedef {StartThreadOptions} ThreadCreateOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/ThreadManager.js
Expand Up @@ -17,7 +17,7 @@ class ThreadManager extends CachedManager {

/**
* The channel this Manager belongs to
* @type {NewsChannel|TextChannel|ForumChannel}
* @type {TextChannel|NewsChannel|ForumChannel}
*/
this.channel = channel;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -3674,19 +3674,21 @@ export class StageInstanceManager extends CachedManager<Snowflake, StageInstance
}

export class ThreadManager extends CachedManager<Snowflake, ThreadChannel, ThreadChannelResolvable> {
protected constructor(channel: TextChannel | NewsChannel, iterable?: Iterable<RawThreadChannelData>);
public channel: TextChannel | NewsChannel;
protected constructor(channel: TextChannel | NewsChannel | ForumChannel, iterable?: Iterable<RawThreadChannelData>);
public channel: TextChannel | NewsChannel | ForumChannel;
public fetch(options: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise<AnyThreadChannel | null>;
public fetch(options?: FetchThreadsOptions, cacheOptions?: { cache?: boolean }): Promise<FetchedThreads>;
public fetchArchived(options?: FetchArchivedThreadOptions, cache?: boolean): Promise<FetchedThreads>;
public fetchActive(cache?: boolean): Promise<FetchedThreads>;
}

export class GuildTextThreadManager<AllowedThreadType> extends ThreadManager {
public channel: TextChannel | NewsChannel;
public create(options: GuildTextThreadCreateOptions<AllowedThreadType>): Promise<ThreadChannel>;
}

export class GuildForumThreadManager extends ThreadManager {
public channel: ForumChannel;
public create(options: GuildForumThreadCreateOptions): Promise<ThreadChannel>;
}

Expand Down

0 comments on commit 14bbc91

Please sign in to comment.