mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
types: Use ThreadChannel and AnyThreadChannel consistently (#10181)
* types: Use `ThreadChannel` and `AnyThreadChannel` consistently Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> * types: use union in typeguard Signed-off-by: cobalt <61329810+RedGuy12@users.noreply.github.com> * types: update `AnyThreadChannel` Signed-off-by: cobalt <61329810+RedGuy12@users.noreply.github.com> * types: fix `CommandOptionResolver` tests Signed-off-by: cobalt <61329810+RedGuy12@users.noreply.github.com> * types: revert caches changes Signed-off-by: cobalt <61329810+RedGuy12@users.noreply.github.com> --------- Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> Signed-off-by: cobalt <61329810+RedGuy12@users.noreply.github.com> Co-authored-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Almeida <github@almeidx.dev>
This commit is contained in:
49
packages/discord.js/typings/index.d.ts
vendored
49
packages/discord.js/typings/index.d.ts
vendored
@@ -2186,7 +2186,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
|||||||
public removeAttachments(): Promise<Message<InGuild>>;
|
public removeAttachments(): Promise<Message<InGuild>>;
|
||||||
public reply(options: string | MessagePayload | MessageReplyOptions): Promise<Message<InGuild>>;
|
public reply(options: string | MessagePayload | MessageReplyOptions): Promise<Message<InGuild>>;
|
||||||
public resolveComponent(customId: string): MessageActionRowComponent | null;
|
public resolveComponent(customId: string): MessageActionRowComponent | null;
|
||||||
public startThread(options: StartThreadOptions): Promise<AnyThreadChannel>;
|
public startThread(options: StartThreadOptions): Promise<PublicThreadChannel<false>>;
|
||||||
public suppressEmbeds(suppress?: boolean): Promise<Message<InGuild>>;
|
public suppressEmbeds(suppress?: boolean): Promise<Message<InGuild>>;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
@@ -3249,7 +3249,9 @@ export class TextChannel extends BaseGuildTextChannel {
|
|||||||
public type: ChannelType.GuildText;
|
public type: ChannelType.GuildText;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AnyThreadChannel<Forum extends boolean = boolean> = PublicThreadChannel<Forum> | PrivateThreadChannel;
|
export type ForumThreadChannel = PublicThreadChannel<true>;
|
||||||
|
export type TextThreadChannel = PublicThreadChannel<false> | PrivateThreadChannel;
|
||||||
|
export type AnyThreadChannel = TextThreadChannel | ForumThreadChannel;
|
||||||
|
|
||||||
export interface PublicThreadChannel<Forum extends boolean = boolean> extends ThreadChannel<Forum> {
|
export interface PublicThreadChannel<Forum extends boolean = boolean> extends ThreadChannel<Forum> {
|
||||||
type: ChannelType.PublicThread | ChannelType.AnnouncementThread;
|
type: ChannelType.PublicThread | ChannelType.AnnouncementThread;
|
||||||
@@ -3298,9 +3300,9 @@ export class ThreadChannel<ThreadOnly extends boolean = boolean> extends BaseCha
|
|||||||
public type: ThreadChannelType;
|
public type: ThreadChannelType;
|
||||||
public get unarchivable(): boolean;
|
public get unarchivable(): boolean;
|
||||||
public delete(reason?: string): Promise<this>;
|
public delete(reason?: string): Promise<this>;
|
||||||
public edit(options: ThreadEditOptions): Promise<AnyThreadChannel>;
|
public edit(options: ThreadEditOptions): Promise<this>;
|
||||||
public join(): Promise<AnyThreadChannel>;
|
public join(): Promise<this>;
|
||||||
public leave(): Promise<AnyThreadChannel>;
|
public leave(): Promise<this>;
|
||||||
public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>;
|
public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>;
|
||||||
public permissionsFor(
|
public permissionsFor(
|
||||||
memberOrRole: GuildMemberResolvable | RoleResolvable,
|
memberOrRole: GuildMemberResolvable | RoleResolvable,
|
||||||
@@ -3308,18 +3310,15 @@ export class ThreadChannel<ThreadOnly extends boolean = boolean> extends BaseCha
|
|||||||
): 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<true> | null>;
|
public fetchStarterMessage(options?: BaseFetchOptions): Promise<Message<true> | null>;
|
||||||
public setArchived(archived?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
public setArchived(archived?: boolean, reason?: string): Promise<this>;
|
||||||
public setAutoArchiveDuration(
|
public setAutoArchiveDuration(autoArchiveDuration: ThreadAutoArchiveDuration, reason?: string): Promise<this>;
|
||||||
autoArchiveDuration: ThreadAutoArchiveDuration,
|
public setInvitable(invitable?: boolean, reason?: string): Promise<this>;
|
||||||
reason?: string,
|
public setLocked(locked?: boolean, reason?: string): Promise<this>;
|
||||||
): Promise<AnyThreadChannel>;
|
public setName(name: string, reason?: string): Promise<this>;
|
||||||
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
|
||||||
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
|
||||||
public setName(name: string, reason?: string): Promise<AnyThreadChannel>;
|
|
||||||
// The following 3 methods can only be run on forum threads.
|
// The following 3 methods can only be run on forum threads.
|
||||||
public setAppliedTags(appliedTags: readonly Snowflake[], reason?: string): Promise<ThreadChannel<true>>;
|
public setAppliedTags(appliedTags: readonly Snowflake[], reason?: string): Promise<If<ThreadOnly, this, never>>;
|
||||||
public pin(reason?: string): Promise<ThreadChannel<true>>;
|
public pin(reason?: string): Promise<If<ThreadOnly, this, never>>;
|
||||||
public unpin(reason?: string): Promise<ThreadChannel<true>>;
|
public unpin(reason?: string): Promise<If<ThreadOnly, this, never>>;
|
||||||
public toString(): ChannelMention;
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4568,7 +4567,7 @@ export class StageInstanceManager extends CachedManager<Snowflake, StageInstance
|
|||||||
|
|
||||||
export class ThreadManager<ThreadOnly extends boolean = boolean> extends CachedManager<
|
export class ThreadManager<ThreadOnly extends boolean = boolean> extends CachedManager<
|
||||||
Snowflake,
|
Snowflake,
|
||||||
ThreadChannel<ThreadOnly>,
|
If<ThreadOnly, ForumThreadChannel, TextThreadChannel>,
|
||||||
ThreadChannelResolvable
|
ThreadChannelResolvable
|
||||||
> {
|
> {
|
||||||
protected constructor(
|
protected constructor(
|
||||||
@@ -4576,7 +4575,10 @@ export class ThreadManager<ThreadOnly extends boolean = boolean> extends CachedM
|
|||||||
iterable?: Iterable<RawThreadChannelData>,
|
iterable?: Iterable<RawThreadChannelData>,
|
||||||
);
|
);
|
||||||
public channel: If<ThreadOnly, ForumChannel | MediaChannel, TextChannel | NewsChannel>;
|
public channel: If<ThreadOnly, ForumChannel | MediaChannel, TextChannel | NewsChannel>;
|
||||||
public fetch(options: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise<AnyThreadChannel | null>;
|
public fetch(
|
||||||
|
options: ThreadChannelResolvable,
|
||||||
|
cacheOptions?: BaseFetchOptions,
|
||||||
|
): Promise<If<ThreadOnly, ForumThreadChannel, TextThreadChannel> | null>;
|
||||||
public fetch(
|
public fetch(
|
||||||
options: FetchThreadsOptions & { archived: FetchArchivedThreadOptions },
|
options: FetchThreadsOptions & { archived: FetchArchivedThreadOptions },
|
||||||
cacheOptions?: { cache?: boolean },
|
cacheOptions?: { cache?: boolean },
|
||||||
@@ -4587,11 +4589,13 @@ export class ThreadManager<ThreadOnly extends boolean = boolean> extends CachedM
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class GuildTextThreadManager<AllowedThreadType> extends ThreadManager<false> {
|
export class GuildTextThreadManager<AllowedThreadType> extends ThreadManager<false> {
|
||||||
public create(options: GuildTextThreadCreateOptions<AllowedThreadType>): Promise<ThreadChannel>;
|
public create(
|
||||||
|
options: GuildTextThreadCreateOptions<AllowedThreadType>,
|
||||||
|
): Promise<AllowedThreadType extends ChannelType.PrivateThread ? PrivateThreadChannel : PublicThreadChannel<false>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GuildForumThreadManager extends ThreadManager<true> {
|
export class GuildForumThreadManager extends ThreadManager<true> {
|
||||||
public create(options: GuildForumThreadCreateOptions): Promise<ThreadChannel>;
|
public create(options: GuildForumThreadCreateOptions): Promise<ForumThreadChannel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThreadMemberManager extends CachedManager<Snowflake, ThreadMember, ThreadMemberResolvable> {
|
export class ThreadMemberManager extends CachedManager<Snowflake, ThreadMember, ThreadMemberResolvable> {
|
||||||
@@ -6792,7 +6796,8 @@ export type Channel =
|
|||||||
| NewsChannel
|
| NewsChannel
|
||||||
| StageChannel
|
| StageChannel
|
||||||
| TextChannel
|
| TextChannel
|
||||||
| AnyThreadChannel
|
| PublicThreadChannel
|
||||||
|
| PrivateThreadChannel
|
||||||
| VoiceChannel
|
| VoiceChannel
|
||||||
| ForumChannel
|
| ForumChannel
|
||||||
| MediaChannel;
|
| MediaChannel;
|
||||||
@@ -6822,7 +6827,7 @@ export type TextChannelResolvable = Snowflake | TextChannel;
|
|||||||
|
|
||||||
export type TextBasedChannelResolvable = Snowflake | TextBasedChannel;
|
export type TextBasedChannelResolvable = Snowflake | TextBasedChannel;
|
||||||
|
|
||||||
export type ThreadChannelResolvable = AnyThreadChannel | Snowflake;
|
export type ThreadChannelResolvable = Snowflake | ThreadChannel;
|
||||||
|
|
||||||
export type ThreadChannelType = ChannelType.AnnouncementThread | ChannelType.PublicThread | ChannelType.PrivateThread;
|
export type ThreadChannelType = ChannelType.AnnouncementThread | ChannelType.PublicThread | ChannelType.PrivateThread;
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,10 @@ const client: Client = new Client({
|
|||||||
maxSize: 200,
|
maxSize: 200,
|
||||||
keepOverLimit: member => member.id === client.user?.id,
|
keepOverLimit: member => member.id === client.user?.id,
|
||||||
},
|
},
|
||||||
|
ThreadManager: {
|
||||||
|
maxSize: 200,
|
||||||
|
keepOverLimit: value => !value.archived,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user