mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
feat: api v9 and threads (#5570)
Co-authored-by: Noel <icrawltogo@gmail.com> Co-authored-by: Amish Shah <dev@shah.gg> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: SynthGhost <60333233+synthghost@users.noreply.github.com> Co-authored-by: SpaceEEC <24881032+SpaceEEC@users.noreply.github.com> Co-authored-by: Elliot <elliot@maisl.fr> Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
205
typings/index.d.ts
vendored
205
typings/index.d.ts
vendored
@@ -16,6 +16,9 @@ declare enum ChannelType {
|
||||
news = 5,
|
||||
store = 6,
|
||||
unknown = 7,
|
||||
news_thread = 10,
|
||||
public_thread = 11,
|
||||
private_thread = 12,
|
||||
stage = 13,
|
||||
}
|
||||
|
||||
@@ -27,6 +30,9 @@ declare enum ChannelTypes {
|
||||
CATEGORY = 4,
|
||||
NEWS = 5,
|
||||
STORE = 6,
|
||||
NEWS_THREAD = 10,
|
||||
PUBLIC_THREAD = 11,
|
||||
PRIVATE_THREAD = 12,
|
||||
STAGE = 13,
|
||||
}
|
||||
|
||||
@@ -371,7 +377,7 @@ declare module 'discord.js' {
|
||||
type CategoryChannelResolvable = Snowflake | CategoryChannel;
|
||||
|
||||
export class Channel extends Base {
|
||||
constructor(client: Client, data?: unknown);
|
||||
constructor(client: Client, data?: unknown, immediatePatch?: boolean);
|
||||
public readonly createdAt: Date;
|
||||
public readonly createdTimestamp: number;
|
||||
public deleted: boolean;
|
||||
@@ -379,7 +385,7 @@ declare module 'discord.js' {
|
||||
public type: keyof typeof ChannelType;
|
||||
public delete(reason?: string): Promise<Channel>;
|
||||
public fetch(force?: boolean): Promise<Channel>;
|
||||
public isText(): this is TextChannel | DMChannel | NewsChannel;
|
||||
public isText(): this is TextChannel | DMChannel | NewsChannel | ThreadChannel;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
@@ -625,6 +631,12 @@ declare module 'discord.js' {
|
||||
MESSAGE_REACTION_REMOVE: 'messageReactionRemove';
|
||||
MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll';
|
||||
MESSAGE_REACTION_REMOVE_EMOJI: 'messageReactionRemoveEmoji';
|
||||
THREAD_CREATE: 'threadCreate';
|
||||
THREAD_DELETE: 'threadDelete';
|
||||
THREAD_UPDATE: 'threadUpdate';
|
||||
THREAD_LIST_SYNC: 'threadListSync';
|
||||
THREAD_MEMBER_UPDATE: 'threadMemberUpdate';
|
||||
THREAD_MEMBERS_UPDATE: 'threadMembersUpdate';
|
||||
USER_UPDATE: 'userUpdate';
|
||||
PRESENCE_UPDATE: 'presenceUpdate';
|
||||
VOICE_SERVER_UPDATE: 'voiceServerUpdate';
|
||||
@@ -715,6 +727,7 @@ declare module 'discord.js' {
|
||||
};
|
||||
APIErrors: APIErrors;
|
||||
ChannelTypes: typeof ChannelTypes;
|
||||
ThreadChannelTypes: ThreadChannelType[];
|
||||
ClientApplicationAssetTypes: {
|
||||
SMALL: 1;
|
||||
BIG: 2;
|
||||
@@ -1222,14 +1235,14 @@ declare module 'discord.js' {
|
||||
}
|
||||
|
||||
export class Message extends Base {
|
||||
constructor(client: Client, data: unknown, channel: TextChannel | DMChannel | NewsChannel);
|
||||
constructor(client: Client, data: unknown, channel: TextChannel | DMChannel | NewsChannel | ThreadChannel);
|
||||
private patch(data: unknown): Message;
|
||||
|
||||
public activity: MessageActivity | null;
|
||||
public applicationID: Snowflake | null;
|
||||
public attachments: Collection<Snowflake, MessageAttachment>;
|
||||
public author: User;
|
||||
public channel: TextChannel | DMChannel | NewsChannel;
|
||||
public channel: TextChannel | DMChannel | NewsChannel | ThreadChannel;
|
||||
public readonly cleanContent: string;
|
||||
public components: MessageActionRow[];
|
||||
public content: string;
|
||||
@@ -1255,6 +1268,7 @@ declare module 'discord.js' {
|
||||
public reactions: ReactionManager;
|
||||
public stickers: Collection<Snowflake, Sticker>;
|
||||
public system: boolean;
|
||||
public thread: ThreadChannel;
|
||||
public tts: boolean;
|
||||
public type: MessageType;
|
||||
public readonly url: string;
|
||||
@@ -1289,6 +1303,11 @@ declare module 'discord.js' {
|
||||
public removeAttachments(): Promise<Message>;
|
||||
public reply(options: string | APIMessage | (ReplyMessageOptions & { split?: false })): Promise<Message>;
|
||||
public reply(options: APIMessage | (ReplyMessageOptions & { split: true | SplitOptions })): Promise<Message[]>;
|
||||
public startThread(
|
||||
name: string,
|
||||
autoArchiveDuration: ThreadAutoArchiveDuration,
|
||||
reason?: string,
|
||||
): Promise<ThreadChannel>;
|
||||
public suppressEmbeds(suppress?: boolean): Promise<Message>;
|
||||
public toJSON(): unknown;
|
||||
public toString(): string;
|
||||
@@ -1514,11 +1533,17 @@ declare module 'discord.js' {
|
||||
|
||||
export class NewsChannel extends TextBasedChannel(GuildChannel) {
|
||||
constructor(guild: Guild, data?: unknown);
|
||||
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||
public messages: MessageManager;
|
||||
public nsfw: boolean;
|
||||
public threads: ThreadManager;
|
||||
public topic: string | null;
|
||||
public type: 'news';
|
||||
public createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>;
|
||||
public setDefaultAutoArchiveDuration(
|
||||
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
|
||||
reason?: string,
|
||||
): Promise<NewsChannel>;
|
||||
public setNSFW(nsfw: boolean, reason?: string): Promise<NewsChannel>;
|
||||
public setType(type: Pick<typeof ChannelType, 'text' | 'news'>, reason?: string): Promise<GuildChannel>;
|
||||
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
||||
@@ -1846,18 +1871,82 @@ declare module 'discord.js' {
|
||||
|
||||
export class TextChannel extends TextBasedChannel(GuildChannel) {
|
||||
constructor(guild: Guild, data?: unknown);
|
||||
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||
public messages: MessageManager;
|
||||
public nsfw: boolean;
|
||||
public type: 'text';
|
||||
public rateLimitPerUser: number;
|
||||
public threads: ThreadManager;
|
||||
public topic: string | null;
|
||||
public createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>;
|
||||
public setDefaultAutoArchiveDuration(
|
||||
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
|
||||
reason?: string,
|
||||
): Promise<TextChannel>;
|
||||
public setNSFW(nsfw: boolean, reason?: string): Promise<TextChannel>;
|
||||
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<TextChannel>;
|
||||
public setType(type: Pick<typeof ChannelType, 'text' | 'news'>, reason?: string): Promise<GuildChannel>;
|
||||
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
||||
}
|
||||
|
||||
export class ThreadChannel extends TextBasedChannel(Channel) {
|
||||
constructor(guild: Guild, data?: object);
|
||||
public archived: boolean;
|
||||
public readonly archivedAt: Date | null;
|
||||
public archiveTimestamp: number | null;
|
||||
public autoArchiveDuration: ThreadAutoArchiveDuration;
|
||||
public readonly editable: boolean;
|
||||
public guild: Guild;
|
||||
public readonly guildMembers: Collection<Snowflake, GuildMember>;
|
||||
public readonly joinable: boolean;
|
||||
public locked: boolean;
|
||||
public readonly manageable: boolean;
|
||||
public readonly sendable: boolean;
|
||||
public memberCount: number | null;
|
||||
public messageCount: number | null;
|
||||
public messages: MessageManager;
|
||||
public members: ThreadMemberManager;
|
||||
public name: string;
|
||||
public ownerID: Snowflake;
|
||||
public readonly parent: TextChannel | NewsChannel | null;
|
||||
public parentID: Snowflake;
|
||||
public rateLimitPerUser: number;
|
||||
public type: ThreadChannelType;
|
||||
public readonly unarchivable: boolean;
|
||||
public delete(reason?: string): Promise<ThreadChannel>;
|
||||
public edit(data: ThreadEditData, reason?: string): Promise<ThreadChannel>;
|
||||
public join(): Promise<ThreadChannel>;
|
||||
public leave(): Promise<ThreadChannel>;
|
||||
public permissionsFor(memberOrRole: GuildMember | Role): Readonly<Permissions>;
|
||||
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
|
||||
public setArchived(archived: boolean, reason?: string): Promise<ThreadChannel>;
|
||||
public setAutoArchiveDuration(
|
||||
autoArchiveDuration: ThreadAutoArchiveDuration,
|
||||
reason?: string,
|
||||
): Promise<ThreadChannel>;
|
||||
public setLocked(locked: boolean, reason?: string): Promise<ThreadChannel>;
|
||||
public setName(name: string, reason?: string): Promise<ThreadChannel>;
|
||||
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<ThreadChannel>;
|
||||
}
|
||||
|
||||
export class ThreadMember extends Base {
|
||||
constructor(thread: ThreadChannel, data?: object);
|
||||
public flags: ThreadMemberFlags;
|
||||
public readonly guildMember: GuildMember | null;
|
||||
public id: Snowflake;
|
||||
public readonly joinedAt: Date | null;
|
||||
public joinedTimestamp: number | null;
|
||||
public readonly manageable: boolean;
|
||||
public thread: ThreadChannel;
|
||||
public readonly user: User | null;
|
||||
public remove(reason?: string): Promise<ThreadMember>;
|
||||
}
|
||||
|
||||
export class ThreadMemberFlags extends BitField<ThreadMemberFlagsString> {
|
||||
public static FLAGS: Record<ThreadMemberFlagsString, number>;
|
||||
public static resolve(bit?: BitFieldResolvable<ThreadMemberFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export class User extends PartialTextBasedChannel(Base) {
|
||||
constructor(client: Client, data: unknown);
|
||||
public avatar: string | null;
|
||||
@@ -2264,6 +2353,7 @@ declare module 'discord.js' {
|
||||
|
||||
export class GuildChannelManager extends BaseManager<Snowflake, GuildChannel, GuildChannelResolvable> {
|
||||
constructor(guild: Guild, iterable?: Iterable<any>);
|
||||
public readonly channelCountWithoutThreads: number;
|
||||
public guild: Guild;
|
||||
public create(name: string, options: GuildChannelCreateOptions & { type: 'voice' }): Promise<VoiceChannel>;
|
||||
public create(name: string, options: GuildChannelCreateOptions & { type: 'category' }): Promise<CategoryChannel>;
|
||||
@@ -2425,6 +2515,33 @@ declare module 'discord.js' {
|
||||
public delete(channel: StageChannel | Snowflake): Promise<void>;
|
||||
}
|
||||
|
||||
export class ThreadManager extends BaseManager<Snowflake, ThreadChannel, ThreadChannelResolvable> {
|
||||
constructor(channel: TextChannel | NewsChannel, iterable?: Iterable<any>);
|
||||
public channel: TextChannel | NewsChannel;
|
||||
public create(options: {
|
||||
name: string;
|
||||
autoArchiveDuration: ThreadAutoArchiveDuration;
|
||||
startMessage?: MessageResolvable;
|
||||
reason?: string;
|
||||
}): Promise<ThreadChannel>;
|
||||
public fetch(options: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise<ThreadChannel | null>;
|
||||
public fetch(
|
||||
options?: { archived?: FetchArchivedThreadOptions; active?: boolean },
|
||||
cacheOptions?: { cache?: boolean },
|
||||
): Promise<FetchedThreads>;
|
||||
public fetchArchived(options?: FetchArchivedThreadOptions, cache?: boolean): Promise<FetchedThreads>;
|
||||
public fetchActive(cache?: boolean): Promise<FetchedThreads>;
|
||||
}
|
||||
|
||||
export class ThreadMemberManager extends Omit<BaseManager<Snowflake, ThreadMember, ThreadMemberResolvable>, 'add'> {
|
||||
constructor(thread: ThreadChannel, iterable?: Iterable<any>);
|
||||
public thread: ThreadChannel;
|
||||
public _add(data: any, cache?: boolean): ThreadMember;
|
||||
public add(member: UserResolvable | '@me', reason?: string): Promise<Snowflake>;
|
||||
public fetch(cache?: boolean): Promise<Collection<Snowflake, ThreadMember>>;
|
||||
public remove(id: Snowflake | '@me', reason?: string): Promise<Snowflake>;
|
||||
}
|
||||
|
||||
export class UserManager extends BaseManager<Snowflake, User, UserResolvable> {
|
||||
constructor(client: Client, iterable?: Iterable<any>);
|
||||
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<User>;
|
||||
@@ -2595,6 +2712,7 @@ declare module 'discord.js' {
|
||||
MAXIMUM_ANIMATED_EMOJIS: 30018;
|
||||
MAXIMUM_SERVER_MEMBERS: 30019;
|
||||
GUILD_ALREADY_HAS_TEMPLATE: 30031;
|
||||
MAXIMUM_THREAD_PARICIPANTS: 30033;
|
||||
MAXIMUM_NON_GUILD_MEMBERS_BANS: 30035;
|
||||
MAXIMUM_BAN_FETCHES: 30037;
|
||||
UNAUTHORIZED: 40001;
|
||||
@@ -2638,11 +2756,18 @@ declare module 'discord.js' {
|
||||
PAYMENT_SOURCE_REQUIRED: 50070;
|
||||
CANNOT_DELETE_COMMUNITY_REQUIRED_CHANNEL: 50074;
|
||||
INVALID_STICKER_SENT: 50081;
|
||||
INVALID_THREAD_ARCHIVE_STATE: 50083;
|
||||
INVALID_THREAD_NOTIFICATION_SETTINGS: 50084;
|
||||
PARAMETER_EARLIER_THAN_CREATION: 50085;
|
||||
TWO_FACTOR_REQUIRED: 60003;
|
||||
NO_USERS_WITH_DISCORDTAG_EXIST: 80004;
|
||||
REACTION_BLOCKED: 90001;
|
||||
RESOURCE_OVERLOADED: 130000;
|
||||
STAGE_ALREADY_OPEN: 150006;
|
||||
MESSAGE_ALREADY_HAS_THREAD: 160004;
|
||||
THREAD_LOCKED: 160005;
|
||||
MAXIMUM_ACTIVE_THREADS: 160006;
|
||||
MAXIMUM_ACTIVE_ANNOUCEMENT_THREAD: 160007;
|
||||
}
|
||||
|
||||
interface ApplicationAsset {
|
||||
@@ -2765,6 +2890,7 @@ declare module 'discord.js' {
|
||||
rateLimitPerUser?: number;
|
||||
lockPermissions?: boolean;
|
||||
permissionOverwrites?: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
|
||||
defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||
rtcRegion?: string | null;
|
||||
}
|
||||
|
||||
@@ -2838,7 +2964,16 @@ declare module 'discord.js' {
|
||||
roleCreate: [role: Role];
|
||||
roleDelete: [role: Role];
|
||||
roleUpdate: [oldRole: Role, newRole: Role];
|
||||
typingStart: [channel: TextChannel | NewsChannel | DMChannel | PartialDMChannel, user: User | PartialUser];
|
||||
threadCreate: [thread: ThreadChannel];
|
||||
threadDelete: [thread: ThreadChannel];
|
||||
threadListSync: [threads: Collection<Snowflake, ThreadChannel>];
|
||||
threadMemberUpdate: [oldMember: ThreadMember, newMember: ThreadMember];
|
||||
threadMembersUpdate: [
|
||||
oldMembers: Collection<Snowflake, ThreadMember>,
|
||||
mewMembers: Collection<Snowflake, ThreadMember>,
|
||||
];
|
||||
threadUpdate: [oldThread: ThreadChannel, newThread: ThreadChannel];
|
||||
typingStart: [channel: Channel | PartialDMChannel, user: User | PartialUser];
|
||||
userUpdate: [oldUser: User | PartialUser, newUser: User];
|
||||
voiceStateUpdate: [oldState: VoiceState, newState: VoiceState];
|
||||
webhookUpdate: [channel: TextChannel];
|
||||
@@ -2972,6 +3107,8 @@ declare module 'discord.js' {
|
||||
name: string;
|
||||
}
|
||||
|
||||
type DateResolvable = Date | number | string;
|
||||
|
||||
interface DeconstructedSnowflake {
|
||||
timestamp: number;
|
||||
readonly date: Date;
|
||||
@@ -3033,7 +3170,9 @@ declare module 'discord.js' {
|
||||
CategoryChannel: typeof CategoryChannel;
|
||||
NewsChannel: typeof NewsChannel;
|
||||
StoreChannel: typeof StoreChannel;
|
||||
ThreadChannel: typeof ThreadChannel;
|
||||
GuildMember: typeof GuildMember;
|
||||
ThreadMember: typeof ThreadMember;
|
||||
Guild: typeof Guild;
|
||||
Message: typeof Message;
|
||||
MessageReaction: typeof MessageReaction;
|
||||
@@ -3067,6 +3206,18 @@ declare module 'discord.js' {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
interface FetchArchivedThreadOptions {
|
||||
type?: 'public' | 'private';
|
||||
fetchAll?: boolean;
|
||||
before?: ThreadChannelResolvable | DateResolvable;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
interface FetchedThreads {
|
||||
threads: Collection<Snowflake, ThreadChannel>;
|
||||
hasMore?: boolean;
|
||||
}
|
||||
|
||||
interface FetchMemberOptions extends BaseFetchOptions {
|
||||
user: UserResolvable;
|
||||
}
|
||||
@@ -3182,7 +3333,16 @@ declare module 'discord.js' {
|
||||
topic?: string;
|
||||
type?: Exclude<
|
||||
keyof typeof ChannelType | ChannelType,
|
||||
'dm' | 'group' | 'unknown' | ChannelType.dm | ChannelType.group | ChannelType.unknown
|
||||
| 'dm'
|
||||
| 'group'
|
||||
| 'unknown'
|
||||
| 'public_thread'
|
||||
| 'private_thread'
|
||||
| ChannelType.dm
|
||||
| ChannelType.group
|
||||
| ChannelType.unknown
|
||||
| ChannelType.public_thread
|
||||
| ChannelType.private_thread
|
||||
>;
|
||||
nsfw?: boolean;
|
||||
parent?: ChannelResolvable;
|
||||
@@ -3535,6 +3695,7 @@ declare module 'discord.js' {
|
||||
| 'SUPPRESS_EMBEDS'
|
||||
| 'SOURCE_MESSAGE_DELETED'
|
||||
| 'URGENT'
|
||||
| 'HAS_THREAD'
|
||||
| 'EPHEMERAL'
|
||||
| 'LOADING';
|
||||
|
||||
@@ -3594,6 +3755,7 @@ declare module 'discord.js' {
|
||||
| InteractionWebhook
|
||||
| TextChannel
|
||||
| NewsChannel
|
||||
| ThreadChannel
|
||||
| DMChannel
|
||||
| User
|
||||
| GuildMember
|
||||
@@ -3620,8 +3782,11 @@ declare module 'discord.js' {
|
||||
| 'GUILD_DISCOVERY_REQUALIFIED'
|
||||
| 'GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING'
|
||||
| 'GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING'
|
||||
| 'THREAD_CREATED'
|
||||
| 'REPLY'
|
||||
| 'APPLICATION_COMMAND';
|
||||
| 'APPLICATION_COMMAND'
|
||||
| 'THREAD_STARTER_MESSAGE'
|
||||
| 'GUILD_INVITE_REMINDER';
|
||||
|
||||
type MFALevel = keyof typeof MFALevels;
|
||||
|
||||
@@ -3691,7 +3856,10 @@ declare module 'discord.js' {
|
||||
| 'MANAGE_WEBHOOKS'
|
||||
| 'MANAGE_EMOJIS'
|
||||
| 'USE_APPLICATION_COMMANDS'
|
||||
| 'REQUEST_TO_SPEAK';
|
||||
| 'REQUEST_TO_SPEAK'
|
||||
| 'MANAGE_THREADS'
|
||||
| 'USE_PUBLIC_THREADS'
|
||||
| 'USE_PRIVATE_THREADS';
|
||||
|
||||
interface RecursiveArray<T> extends ReadonlyArray<T | RecursiveArray<T>> {}
|
||||
|
||||
@@ -3969,6 +4137,24 @@ declare module 'discord.js' {
|
||||
privacyLevel?: PrivacyLevel | number;
|
||||
}
|
||||
|
||||
type ThreadAutoArchiveDuration = 60 | 1440 | 4320 | 10080;
|
||||
|
||||
type ThreadChannelResolvable = ThreadChannel | Snowflake;
|
||||
|
||||
type ThreadChannelType = 'news_thread' | 'public_thread' | 'private_thread';
|
||||
|
||||
interface ThreadEditData {
|
||||
name?: string;
|
||||
archived?: boolean;
|
||||
autoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||
rateLimitPeruser?: number;
|
||||
locked?: boolean;
|
||||
}
|
||||
|
||||
type ThreadMemberFlagsString = '';
|
||||
|
||||
type ThreadMemberResolvable = ThreadMember | UserResolvable;
|
||||
|
||||
type UserFlagsString =
|
||||
| 'DISCORD_EMPLOYEE'
|
||||
| 'PARTNERED_SERVER_OWNER'
|
||||
@@ -3984,7 +4170,7 @@ declare module 'discord.js' {
|
||||
| 'EARLY_VERIFIED_BOT_DEVELOPER'
|
||||
| 'DISCORD_CERTIFIED_MODERATOR';
|
||||
|
||||
type UserResolvable = User | Snowflake | Message | GuildMember;
|
||||
type UserResolvable = User | Snowflake | Message | GuildMember | ThreadMember;
|
||||
|
||||
interface Vanity {
|
||||
code: string | null;
|
||||
@@ -4012,6 +4198,7 @@ declare module 'discord.js' {
|
||||
interface WebhookMessageOptions extends Omit<MessageOptions, 'reply'> {
|
||||
username?: string;
|
||||
avatarURL?: string;
|
||||
threadID?: Snowflake;
|
||||
}
|
||||
|
||||
type WebhookType = keyof typeof WebhookTypes;
|
||||
|
||||
Reference in New Issue
Block a user