mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +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
|
* The parent channel of this thread
|
||||||
* @type {?(NewsChannel|TextChannel)}
|
* @type {?(NewsChannel|TextChannel|ForumChannel)}
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get parent() {
|
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;
|
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;
|
type: ChannelType.PublicThread | ChannelType.AnnouncementThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrivateThreadChannel extends ThreadChannel {
|
export interface PrivateThreadChannel extends ThreadChannel<false> {
|
||||||
get createdTimestamp(): number;
|
get createdTimestamp(): number;
|
||||||
get createdAt(): Date;
|
get createdAt(): Date;
|
||||||
type: ChannelType.PrivateThread;
|
type: ChannelType.PrivateThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [
|
export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedChannelMixin(BaseChannel, true, [
|
||||||
'fetchWebhooks',
|
'fetchWebhooks',
|
||||||
'createWebhook',
|
'createWebhook',
|
||||||
'setNSFW',
|
'setNSFW',
|
||||||
@@ -2609,7 +2609,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [
|
|||||||
public members: ThreadMemberManager;
|
public members: ThreadMemberManager;
|
||||||
public name: string;
|
public name: string;
|
||||||
public ownerId: Snowflake | null;
|
public ownerId: Snowflake | null;
|
||||||
public get parent(): TextChannel | NewsChannel | null;
|
public get parent(): If<Forum, ForumChannel, TextChannel | NewsChannel> | null;
|
||||||
public parentId: Snowflake | null;
|
public parentId: Snowflake | null;
|
||||||
public rateLimitPerUser: number | null;
|
public rateLimitPerUser: number | null;
|
||||||
public type: ThreadChannelType;
|
public type: ThreadChannelType;
|
||||||
@@ -2633,7 +2633,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, true, [
|
|||||||
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setName(name: string, 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;
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3698,22 +3698,24 @@ export class StageInstanceManager extends CachedManager<Snowflake, StageInstance
|
|||||||
public delete(channel: StageChannelResolvable): Promise<void>;
|
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>);
|
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: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise<AnyThreadChannel | null>;
|
||||||
public fetch(options?: FetchThreadsOptions, cacheOptions?: { cache?: boolean }): Promise<FetchedThreads>;
|
public fetch(options?: FetchThreadsOptions, cacheOptions?: { cache?: boolean }): Promise<FetchedThreads>;
|
||||||
public fetchArchived(options?: FetchArchivedThreadOptions, cache?: boolean): Promise<FetchedThreads>;
|
public fetchArchived(options?: FetchArchivedThreadOptions, cache?: boolean): Promise<FetchedThreads>;
|
||||||
public fetchActive(cache?: boolean): Promise<FetchedThreads>;
|
public fetchActive(cache?: boolean): Promise<FetchedThreads>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GuildTextThreadManager<AllowedThreadType> extends ThreadManager {
|
export class GuildTextThreadManager<AllowedThreadType> extends ThreadManager<false> {
|
||||||
public channel: TextChannel | NewsChannel;
|
|
||||||
public create(options: GuildTextThreadCreateOptions<AllowedThreadType>): Promise<ThreadChannel>;
|
public create(options: GuildTextThreadCreateOptions<AllowedThreadType>): Promise<ThreadChannel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GuildForumThreadManager extends ThreadManager {
|
export class GuildForumThreadManager extends ThreadManager<true> {
|
||||||
public channel: ForumChannel;
|
|
||||||
public create(options: GuildForumThreadCreateOptions): Promise<ThreadChannel>;
|
public create(options: GuildForumThreadCreateOptions): Promise<ThreadChannel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ import {
|
|||||||
ModalSubmitInteraction,
|
ModalSubmitInteraction,
|
||||||
ForumChannel,
|
ForumChannel,
|
||||||
ChannelFlagsBitField,
|
ChannelFlagsBitField,
|
||||||
|
GuildForumThreadManager,
|
||||||
|
GuildTextThreadManager,
|
||||||
} from '.';
|
} from '.';
|
||||||
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||||
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
|
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
|
||||||
@@ -1224,6 +1226,8 @@ expectType<Promise<number[]>>(shardClientUtil.broadcastEval(async () => 1));
|
|||||||
|
|
||||||
declare const dmChannel: DMChannel;
|
declare const dmChannel: DMChannel;
|
||||||
declare const threadChannel: ThreadChannel;
|
declare const threadChannel: ThreadChannel;
|
||||||
|
declare const threadChannelFromForum: ThreadChannel<true>;
|
||||||
|
declare const threadChannelNotFromForum: ThreadChannel<false>;
|
||||||
declare const newsChannel: NewsChannel;
|
declare const newsChannel: NewsChannel;
|
||||||
declare const textChannel: TextChannel;
|
declare const textChannel: TextChannel;
|
||||||
declare const voiceChannel: VoiceChannel;
|
declare const voiceChannel: VoiceChannel;
|
||||||
@@ -1231,6 +1235,11 @@ declare const guild: Guild;
|
|||||||
declare const user: User;
|
declare const user: User;
|
||||||
declare const guildMember: GuildMember;
|
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
|
// Test whether the structures implement send
|
||||||
expectType<TextBasedChannelFields<false>['send']>(dmChannel.send);
|
expectType<TextBasedChannelFields<false>['send']>(dmChannel.send);
|
||||||
expectType<TextBasedChannelFields<true>['send']>(threadChannel.send);
|
expectType<TextBasedChannelFields<true>['send']>(threadChannel.send);
|
||||||
@@ -1406,6 +1415,14 @@ declare const guildChannelManager: GuildChannelManager;
|
|||||||
expectType<TextBasedChannel>(message.channel.messages.channel);
|
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;
|
declare const messageManager: MessageManager;
|
||||||
{
|
{
|
||||||
expectType<Promise<Message>>(messageManager.fetch('1234567890'));
|
expectType<Promise<Message>>(messageManager.fetch('1234567890'));
|
||||||
|
|||||||
Reference in New Issue
Block a user