mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(ThreadChannel): Add forum channel to parent (#8664)
fix(ThreadChannel): add forum channel to parent Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -246,7 +246,7 @@ class ThreadChannel extends BaseChannel {
|
||||
|
||||
/**
|
||||
* The parent channel of this thread
|
||||
* @type {?(NewsChannel|TextChannel)}
|
||||
* @type {?(NewsChannel|TextChannel|ForumChannel)}
|
||||
* @readonly
|
||||
*/
|
||||
get parent() {
|
||||
|
||||
26
packages/discord.js/typings/index.d.ts
vendored
26
packages/discord.js/typings/index.d.ts
vendored
@@ -2565,19 +2565,19 @@ export class TextChannel extends BaseGuildTextChannel {
|
||||
public type: ChannelType.GuildText;
|
||||
}
|
||||
|
||||
export type AnyThreadChannel = PublicThreadChannel | PrivateThreadChannel;
|
||||
export type AnyThreadChannel<Forum extends boolean = boolean> = PublicThreadChannel<Forum> | PrivateThreadChannel;
|
||||
|
||||
export interface PublicThreadChannel extends ThreadChannel {
|
||||
export interface PublicThreadChannel<Forum extends boolean = boolean> extends ThreadChannel<Forum> {
|
||||
type: ChannelType.PublicThread | ChannelType.AnnouncementThread;
|
||||
}
|
||||
|
||||
export interface PrivateThreadChannel extends ThreadChannel {
|
||||
export interface PrivateThreadChannel extends ThreadChannel<false> {
|
||||
get createdTimestamp(): number;
|
||||
get createdAt(): Date;
|
||||
type: ChannelType.PrivateThread;
|
||||
}
|
||||
|
||||
export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [
|
||||
export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedChannelMixin(BaseChannel, true, [
|
||||
'fetchWebhooks',
|
||||
'createWebhook',
|
||||
'setNSFW',
|
||||
@@ -2609,7 +2609,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [
|
||||
public members: ThreadMemberManager;
|
||||
public name: string;
|
||||
public ownerId: Snowflake | null;
|
||||
public get parent(): TextChannel | NewsChannel | null;
|
||||
public get parent(): If<Forum, ForumChannel, TextChannel | NewsChannel> | null;
|
||||
public parentId: Snowflake | null;
|
||||
public rateLimitPerUser: number | null;
|
||||
public type: ThreadChannelType;
|
||||
@@ -2633,7 +2633,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [
|
||||
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||
public setName(name: string, reason?: string): Promise<AnyThreadChannel>;
|
||||
public setAppliedTags(appliedTags: Snowflake[], reason?: string): Promise<ThreadChannel>;
|
||||
public setAppliedTags(appliedTags: Snowflake[], reason?: string): Promise<ThreadChannel<true>>;
|
||||
public toString(): ChannelMention;
|
||||
}
|
||||
|
||||
@@ -3698,22 +3698,24 @@ export class StageInstanceManager extends CachedManager<Snowflake, StageInstance
|
||||
public delete(channel: StageChannelResolvable): Promise<void>;
|
||||
}
|
||||
|
||||
export class ThreadManager extends CachedManager<Snowflake, ThreadChannel, ThreadChannelResolvable> {
|
||||
export class ThreadManager<Forum extends boolean = boolean> extends CachedManager<
|
||||
Snowflake,
|
||||
ThreadChannel<Forum>,
|
||||
ThreadChannelResolvable
|
||||
> {
|
||||
protected constructor(channel: TextChannel | NewsChannel | ForumChannel, iterable?: Iterable<RawThreadChannelData>);
|
||||
public channel: TextChannel | NewsChannel | ForumChannel;
|
||||
public channel: If<Forum, ForumChannel, TextChannel | NewsChannel>;
|
||||
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;
|
||||
export class GuildTextThreadManager<AllowedThreadType> extends ThreadManager<false> {
|
||||
public create(options: GuildTextThreadCreateOptions<AllowedThreadType>): Promise<ThreadChannel>;
|
||||
}
|
||||
|
||||
export class GuildForumThreadManager extends ThreadManager {
|
||||
public channel: ForumChannel;
|
||||
export class GuildForumThreadManager extends ThreadManager<true> {
|
||||
public create(options: GuildForumThreadCreateOptions): Promise<ThreadChannel>;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,8 @@ import {
|
||||
ModalSubmitInteraction,
|
||||
ForumChannel,
|
||||
ChannelFlagsBitField,
|
||||
GuildForumThreadManager,
|
||||
GuildTextThreadManager,
|
||||
} from '.';
|
||||
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
|
||||
@@ -1224,6 +1226,8 @@ expectType<Promise<number[]>>(shardClientUtil.broadcastEval(async () => 1));
|
||||
|
||||
declare const dmChannel: DMChannel;
|
||||
declare const threadChannel: ThreadChannel;
|
||||
declare const threadChannelFromForum: ThreadChannel<true>;
|
||||
declare const threadChannelNotFromForum: ThreadChannel<false>;
|
||||
declare const newsChannel: NewsChannel;
|
||||
declare const textChannel: TextChannel;
|
||||
declare const voiceChannel: VoiceChannel;
|
||||
@@ -1231,6 +1235,11 @@ declare const guild: Guild;
|
||||
declare const user: User;
|
||||
declare const guildMember: GuildMember;
|
||||
|
||||
// Test thread channels' parent inference
|
||||
expectType<TextChannel | NewsChannel | ForumChannel | null>(threadChannel.parent);
|
||||
expectType<ForumChannel | null>(threadChannelFromForum.parent);
|
||||
expectType<TextChannel | NewsChannel | null>(threadChannelNotFromForum.parent);
|
||||
|
||||
// Test whether the structures implement send
|
||||
expectType<TextBasedChannelFields<false>['send']>(dmChannel.send);
|
||||
expectType<TextBasedChannelFields<true>['send']>(threadChannel.send);
|
||||
@@ -1406,6 +1415,14 @@ declare const guildChannelManager: GuildChannelManager;
|
||||
expectType<TextBasedChannel>(message.channel.messages.channel);
|
||||
}
|
||||
|
||||
declare const guildForumThreadManager: GuildForumThreadManager;
|
||||
expectType<ForumChannel>(guildForumThreadManager.channel);
|
||||
|
||||
declare const guildTextThreadManager: GuildTextThreadManager<
|
||||
ChannelType.PublicThread | ChannelType.PrivateThread | ChannelType.AnnouncementThread
|
||||
>;
|
||||
expectType<TextChannel | NewsChannel>(guildTextThreadManager.channel);
|
||||
|
||||
declare const messageManager: MessageManager;
|
||||
{
|
||||
expectType<Promise<Message>>(messageManager.fetch('1234567890'));
|
||||
|
||||
Reference in New Issue
Block a user