UNPKG

discord.js-selfbot-v13

Version:

A unofficial discord.js fork for creating selfbots [Based on discord.js v13]

1,231 lines (1,150 loc) 279 kB
import { blockQuote, bold, channelMention, codeBlock, ContextMenuCommandBuilder, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, italic, quote, roleMention, SlashCommandBuilder, spoiler, strikethrough, time, TimestampStyles, TimestampStylesString, underscore, userMention, } from '@discordjs/builders'; import { Collection } from '@discordjs/collection'; import { APIActionRowComponent, APIApplicationCommandInteractionData, APIApplicationCommandOption, APIApplicationCommandPermission, APIAuditLogChange, APIButtonComponent, APIEmbed, APIEmoji, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessage, APIMessageActionRowComponent, APIMessageComponent, APIModalActionRowComponent, APIOverwrite, APIPartialChannel, APIPartialEmoji, APIPartialGuild, APIRole, APISelectMenuComponent, APITemplateSerializedSourceGuild, APIUser, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, MessageActivityType, RESTPostAPIApplicationCommandsJSONBody, Snowflake, LocalizationMap, LocaleString, APIGuildMember, APIChannel, } from 'discord-api-types/v9'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; import { AgentOptions } from 'node:https'; import { Response } from 'node-fetch'; import { Stream } from 'node:stream'; import { MessagePort, Worker } from 'node:worker_threads'; import * as WebSocket from 'ws'; import { ActivityTypes, ApplicationCommandOptionTypes, ApplicationCommandPermissionTypes, ApplicationCommandTypes, AutoModerationActionTypes, AutoModerationRuleEventTypes, AutoModerationRuleKeywordPresetTypes, AutoModerationRuleTriggerTypes, ChannelTypes, DefaultMessageNotificationLevels, ExplicitContentFilterLevels, InteractionResponseTypes, InteractionTypes, InviteTargetType, MembershipStates, MessageButtonStyles, MessageComponentTypes, MessageTypes, MFALevels, NSFWLevels, OverwriteTypes, PremiumTiers, PrivacyLevels, StickerFormatTypes, StickerTypes, TextInputStyles, VerificationLevels, WebhookTypes, GuildScheduledEventEntityTypes, GuildScheduledEventStatuses, GuildScheduledEventPrivacyLevels, VideoQualityModes, SortOrderType, ForumLayoutType, ApplicationRoleConnectionMetadataTypes, RelationshipTypes, SelectMenuComponentTypes, } from './enums'; import { APIApplicationRoleConnectionMetadata, APIAutoModerationRule, GatewayAutoModerationActionExecutionDispatchData, RawActivityData, RawAnonymousGuildData, RawApplicationCommandData, RawApplicationData, RawBaseGuildData, RawChannelData, RawDMChannelData, RawEmojiData, RawGuildAuditLogData, RawGuildAuditLogEntryData, RawGuildBanData, RawGuildChannelData, RawGuildData, RawGuildEmojiData, RawGuildMemberData, RawGuildPreviewData, RawGuildScheduledEventData, RawGuildTemplateData, RawIntegrationApplicationData, RawIntegrationData, RawInteractionData, RawInviteData, RawInviteGuildData, RawInviteStageInstance, RawMessageAttachmentData, RawMessageButtonInteractionData, RawMessageComponentInteractionData, RawMessageData, RawMessagePayloadData, RawMessageReactionData, RawMessageSelectMenuInteractionData, RawModalSubmitInteractionData, RawOAuth2GuildData, RawPartialGroupDMChannelData, RawPartialMessageData, RawPermissionOverwriteData, RawPresenceData, RawReactionEmojiData, RawRichPresenceAssets, RawRoleData, RawStageInstanceData, RawStickerData, RawStickerPackData, RawTeamData, RawTeamMemberData, RawTextInputComponentData, RawThreadChannelData, RawThreadMemberData, RawTypingData, RawUserData, RawVoiceRegionData, RawVoiceStateData, RawWebhookData, RawWelcomeChannelData, RawWelcomeScreenData, RawWidgetData, RawWidgetMemberData, } from './rawDataTypes'; //#region Classes // RPC by aiko-chan-ai export interface RichButton { name: string; url: string; } export class RichPresence { public constructor(client?: Client, data?: object, IPC?: boolean); public application_id: Snowflake | null; public assets: RichPresenceAssets | null; public buttons: string[]; public details: string | null; public name: string; public party: { id: string | null; size: [number, number]; } | null; public state: string | null; public timestamps: { start: Date | null; end: Date | null; } | null; public type: ActivityType; public url: string | null; public ipc: boolean; public setAssetsLargeImage(image?: string): this; public setAssetsLargeText(text?: string): this; public setAssetsSmallImage(image?: string): this; public setAssetsSmallText(text?: string): this; public setName(name?: string): this; public setURL(url?: string): this; public setType(type?: ActivityType): this; public setApplicationId(id?: Snowflake): this; public setDetails(details?: string): this; public setState(state?: string): this; public setParty(party?: { max: number; current: number; id?: string }): this; public setStartTimestamp(timestamp?: Date): this; public setEndTimestamp(timestamp?: Date): this; public setButtons(...button: RichButton[]): this; public addButton(name: string, url: string): this; public static getExternal( client: Client, applicationId: Snowflake, image1: string, image2: string, ): Promise<ExternalAssets[]>; public toJSON(): object; public toString(): string; } export class DiscordAuthWebsocket extends EventEmitter { constructor(); public token: string; public readonly user: { id: Snowflake; username: string; discriminator: number; avatar: string; }; public readonly exprire: Date; public readonly AuthURL: string; public connect(client?: Client): Promise<void>; public destroy(): void; public generateQR(): void; public on(event: 'ready', listener: (client: this) => void): this; public on(event: 'finish', listener: (token: string) => void): this; public on(event: 'cancel' | 'pending', listener: (user: RawUserData) => void): this; public on(event: 'closed', listener: () => void): this; public on(event: string, listener: (...args: any[]) => Awaitable<void>): this; } export interface ExternalAssets { url: string; external_asset_path: string; } export interface SpotifyMetadata { album_id: string; artist_ids: string[]; } export class SpotifyRPC extends RichPresence { public constructor(client: Client, data?: object); public application_id: Snowflake | null; public client: Client; public assets: RichPresenceAssets | null; public buttons: string[]; public details: string | null; public name: string; public sync_id: string; public id: string; public flags: number; public party: { id: string | null; size: [number, number]; } | null; public state: string | null; public timestamps: { start: Date | null; end: Date | null; } | null; public type: ActivityType; public url: string | null; public metadata: SpotifyMetadata; public setAssetsLargeImage(image?: string): this; public setAssetsSmallImage(image?: string): this; public setSongId(id: string): this; public addArtistId(id: string): this; public setArtistIds(...ids: string[]): this; public setAlbumId(id: string): this; } export class CustomStatus { public constructor(data?: object); public emoji: EmojiIdentifierResolvable; public state: string; public setEmoji(emoji?: EmojiIdentifierResolvable): this; public setState(state: string): this; public toJSON(): object; public toString(): string; } export class Activity { private constructor(presence: Presence, data?: RawActivityData); public readonly presence: Presence; public applicationId: Snowflake | null; public assets: RichPresenceAssets | null; public buttons: string[]; public readonly createdAt: Date; public createdTimestamp: number; public details: string | null; public emoji: Emoji | null; public flags: Readonly<ActivityFlags>; public id: string; public name: string; public party: { id: string | null; size: [number, number]; } | null; public platform: ActivityPlatform | null; public sessionId: string | null; public state: string | null; public syncId: string | null; public timestamps: { start: Date | null; end: Date | null; } | null; public type: ActivityType; public url: string | null; public equals(activity: Activity): boolean; } export class ActivityFlags extends BitField<ActivityFlagsString> { public static FLAGS: Record<ActivityFlagsString, number>; public static resolve(bit?: BitFieldResolvable<ActivityFlagsString, number>): number; } export class PurchasedFlags extends BitField<PurchasedFlagsString> { public static FLAGS: Record<PurchasedFlagsString, number>; public static resolve(bit?: BitFieldResolvable<PurchasedFlagsString, number>): number; } export class PremiumUsageFlags extends BitField<PremiumUsageFlagsString> { public static FLAGS: Record<PremiumUsageFlagsString, number>; public static resolve(bit?: BitFieldResolvable<PremiumUsageFlagsString, number>): number; } export abstract class AnonymousGuild extends BaseGuild { protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean); public banner: string | null; public description: string | null; public nsfwLevel: NSFWLevel; public premiumSubscriptionCount: number | null; public splash: string | null; public vanityURLCode: string | null; public verificationLevel: VerificationLevel; public bannerURL(options?: StaticImageURLOptions): string | null; public splashURL(options?: StaticImageURLOptions): string | null; } export abstract class Application extends Base { protected constructor(client: Client, data: RawApplicationData); public readonly createdAt: Date; public readonly createdTimestamp: number; public description: string | null; public icon: string | null; public id: Snowflake; public name: string | null; public roleConnectionsVerificationURL: string | null; public approximateGuildCount: number | null; public botPublic: boolean | null; public botRequireCodeGrant: boolean | null; public commands: ApplicationCommandManager; public cover: string | null; public flags: Readonly<ApplicationFlags>; public guildId: Snowflake | null; public readonly guild: Guild | null; public tags: string[]; public installParams: ClientApplicationInstallParams | null; public customInstallURL: string | null; public owner: User | Team | null; public readonly partial: boolean; public rpcOrigins: string[]; public fetch(): Promise<Application>; public fetchRoleConnectionMetadataRecords(): Promise<ApplicationRoleConnectionMetadata[]>; public coverURL(options?: StaticImageURLOptions): string | null; /** @deprecated This method is deprecated as it is unsupported and will be removed in the next major version. */ public fetchAssets(): Promise<ApplicationAsset[]>; public iconURL(options?: StaticImageURLOptions): string | null; public toJSON(): unknown; public toString(): string | null; } export class ApplicationCommand<PermissionsFetchType = {}> extends Base { private constructor(client: Client, data: RawApplicationCommandData, guild?: Guild, guildId?: Snowflake); public applicationId: Snowflake; public readonly createdAt: Date; public readonly createdTimestamp: number; /** @deprecated Use {@link defaultMemberPermissions} and {@link dmPermission} instead. */ public defaultPermission: boolean; public defaultMemberPermissions: Readonly<Permissions> | null; public description: string; public descriptionLocalizations: LocalizationMap | null; public descriptionLocalized: string | null; public dmPermission: boolean | null; public guild: Guild | null; public guildId: Snowflake | null; public readonly manager: ApplicationCommandManager; public id: Snowflake; public name: string; public nameLocalizations: LocalizationMap | null; public nameLocalized: string | null; public options: (ApplicationCommandOption & { nameLocalized?: string; descriptionLocalized?: string })[]; public permissions: ApplicationCommandPermissionsManager< PermissionsFetchType, PermissionsFetchType, PermissionsFetchType, Guild | null, Snowflake >; public type: ApplicationCommandType; public version: Snowflake; public delete(): Promise<ApplicationCommand<PermissionsFetchType>>; public edit(data: Partial<ApplicationCommandData>): Promise<ApplicationCommand<PermissionsFetchType>>; public setName(name: string): Promise<ApplicationCommand<PermissionsFetchType>>; public setNameLocalizations(nameLocalizations: LocalizationMap): Promise<ApplicationCommand<PermissionsFetchType>>; public setDescription(description: string): Promise<ApplicationCommand<PermissionsFetchType>>; public setDescriptionLocalizations( descriptionLocalizations: LocalizationMap, ): Promise<ApplicationCommand<PermissionsFetchType>>; /** @deprecated Use {@link setDefaultMemberPermissions} and {@link setDMPermission} instead. */ public setDefaultPermission(defaultPermission?: boolean): Promise<ApplicationCommand<PermissionsFetchType>>; public setDefaultMemberPermissions( defaultMemberPermissions: PermissionResolvable | null, ): Promise<ApplicationCommand<PermissionsFetchType>>; public setDMPermission(dmPermission?: boolean): Promise<ApplicationCommand<PermissionsFetchType>>; public setOptions(options: ApplicationCommandOptionData[]): Promise<ApplicationCommand<PermissionsFetchType>>; public equals( command: ApplicationCommand | ApplicationCommandData | RawApplicationCommandData, enforceOptionorder?: boolean, ): boolean; public static optionsEqual( existing: ApplicationCommandOption[], options: ApplicationCommandOption[] | ApplicationCommandOptionData[] | APIApplicationCommandOption[], enforceOptionorder?: boolean, ): boolean; private static _optionEquals( existing: ApplicationCommandOption, options: ApplicationCommandOption | ApplicationCommandOptionData | APIApplicationCommandOption, enforceOptionorder?: boolean, ): boolean; private static transformOption(option: ApplicationCommandOptionData, received?: boolean): unknown; private static transformCommand(command: ApplicationCommandData): RESTPostAPIApplicationCommandsJSONBody; private static isAPICommandData(command: object): command is RESTPostAPIApplicationCommandsJSONBody; } export class ApplicationRoleConnectionMetadata { private constructor(data: APIApplicationRoleConnectionMetadata); public name: string; public nameLocalizations: LocalizationMap | null; public description: string; public descriptionLocalizations: LocalizationMap | null; public key: string; public type: ApplicationRoleConnectionMetadataTypes; } export type ApplicationResolvable = Application | Activity | Snowflake; export type AutoModerationRuleResolvable = AutoModerationRule | Snowflake; export class ApplicationFlags extends BitField<ApplicationFlagsString> { public static FLAGS: Record<ApplicationFlagsString, number>; public static resolve(bit?: BitFieldResolvable<ApplicationFlagsString, number>): number; } export abstract class Base { public constructor(client: Client); public readonly client: Client; public toJSON(...props: Record<string, boolean | string>[]): unknown; public valueOf(): string; } export class BaseClient extends EventEmitter { public constructor(options?: ClientOptions | WebhookClientOptions); private readonly api: unknown; private rest: unknown; private decrementMaxListeners(): void; private incrementMaxListeners(): void; public on<K extends keyof BaseClientEvents>( event: K, listener: (...args: BaseClientEvents[K]) => Awaitable<void>, ): this; public on<S extends string | symbol>( event: Exclude<S, keyof BaseClientEvents>, listener: (...args: any[]) => Awaitable<void>, ): this; public once<K extends keyof BaseClientEvents>( event: K, listener: (...args: BaseClientEvents[K]) => Awaitable<void>, ): this; public once<S extends string | symbol>( event: Exclude<S, keyof BaseClientEvents>, listener: (...args: any[]) => Awaitable<void>, ): this; public emit<K extends keyof BaseClientEvents>(event: K, ...args: BaseClientEvents[K]): boolean; public emit<S extends string | symbol>(event: Exclude<S, keyof BaseClientEvents>, ...args: unknown[]): boolean; public off<K extends keyof BaseClientEvents>( event: K, listener: (...args: BaseClientEvents[K]) => Awaitable<void>, ): this; public off<S extends string | symbol>( event: Exclude<S, keyof BaseClientEvents>, listener: (...args: any[]) => Awaitable<void>, ): this; public removeAllListeners<K extends keyof BaseClientEvents>(event?: K): this; public removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof BaseClientEvents>): this; public options: ClientOptions | WebhookClientOptions; public destroy(): void; public toJSON(...props: Record<string, boolean | string>[]): unknown; } export type GuildCacheMessage<Cached extends CacheType> = CacheTypeReducer< Cached, Message<true>, APIMessage, Message | APIMessage, Message | APIMessage >; export interface InteractionResponseFields<Cached extends CacheType = CacheType> { deferred: boolean; ephemeral: boolean | null; replied: boolean; webhook: InteractionWebhook; reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>; reply(options: string | MessagePayload | InteractionReplyOptions): Promise<void>; deleteReply(message?: MessageResolvable | '@original'): Promise<void>; editReply(options: string | MessagePayload | InteractionEditReplyOptions): Promise<GuildCacheMessage<Cached>>; deferReply(options: InteractionDeferReplyOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>; deferReply(options?: InteractionDeferReplyOptions): Promise<void>; fetchReply(message?: MessageResolvable | '@original'): Promise<GuildCacheMessage<Cached>>; followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<GuildCacheMessage<Cached>>; } export abstract class BaseCommandInteraction<Cached extends CacheType = CacheType> extends Interaction<Cached> { public readonly command: ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null; public options: Omit< CommandInteractionOptionResolver<Cached>, | 'getMessage' | 'getFocused' | 'getMentionable' | 'getRole' | 'getNumber' | 'getInteger' | 'getString' | 'getChannel' | 'getBoolean' | 'getSubcommandGroup' | 'getSubcommand' | 'getAttachment' >; public channelId: Snowflake; public commandId: Snowflake; public commandName: string; public deferred: boolean; public ephemeral: boolean | null; public replied: boolean; public webhook: InteractionWebhook; public awaitModalSubmit( options: AwaitModalSubmitOptions<ModalSubmitInteraction>, ): Promise<ModalSubmitInteraction<Cached>>; public inGuild(): this is BaseCommandInteraction<'raw' | 'cached'>; public inCachedGuild(): this is BaseCommandInteraction<'cached'>; public inRawGuild(): this is BaseCommandInteraction<'raw'>; public deferReply(options: InteractionDeferReplyOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>; public deferReply(options?: InteractionDeferReplyOptions): Promise<void>; public deleteReply(message?: MessageResolvable | '@original'): Promise<void>; public editReply(options: string | MessagePayload | InteractionEditReplyOptions): Promise<GuildCacheMessage<Cached>>; public fetchReply(message?: MessageResolvable | '@original'): Promise<GuildCacheMessage<Cached>>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<GuildCacheMessage<Cached>>; public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>; public reply(options: string | MessagePayload | InteractionReplyOptions): Promise<void>; public showModal(modal: Modal | ModalOptions): Promise<void>; private transformOption( option: APIApplicationCommandOption, resolved: APIApplicationCommandInteractionData['resolved'], ): CommandInteractionOption<Cached>; private transformResolved( resolved: APIApplicationCommandInteractionData['resolved'], ): CommandInteractionResolvedData<Cached>; } export abstract class BaseGuild extends Base { protected constructor(client: Client, data: RawBaseGuildData); public readonly createdAt: Date; public readonly createdTimestamp: number; public features: GuildFeatures[]; public icon: string | null; public id: Snowflake; public name: string; public readonly nameAcronym: string; public readonly partnered: boolean; public readonly verified: boolean; public fetch(): Promise<Guild>; public iconURL(options?: ImageURLOptions): string | null; public toString(): string; } export class BaseGuildEmoji extends Emoji { protected constructor(client: Client, data: RawGuildEmojiData, guild: Guild | GuildPreview); public available: boolean | null; public readonly createdAt: Date; public readonly createdTimestamp: number; public guild: Guild | GuildPreview; public id: Snowflake; public managed: boolean | null; public requiresColons: boolean | null; } export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel) { protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean); public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration; public defaultThreadRateLimitPerUser: number | null; public rateLimitPerUser: number | null; public nsfw: boolean; public threads: GuildTextThreadManager<AllowedThreadTypeForTextChannel | AllowedThreadTypeForNewsChannel>; public topic: string | null; public createInvite(options?: CreateInviteOptions): Promise<Invite>; public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>; public setDefaultAutoArchiveDuration( defaultAutoArchiveDuration: ThreadAutoArchiveDuration | 'MAX', reason?: string, ): Promise<this>; public setTopic(topic: string | null, reason?: string): Promise<this>; public setType(type: Pick<typeof ChannelTypes, 'GUILD_TEXT'>, reason?: string): Promise<TextChannel>; public setType(type: Pick<typeof ChannelTypes, 'GUILD_NEWS'>, reason?: string): Promise<NewsChannel>; } export class BaseGuildVoiceChannel extends TextBasedChannelMixin(GuildChannel, ['lastPinTimestamp', 'lastPinAt']) { public constructor(guild: Guild, data?: RawGuildChannelData); public readonly members: Collection<Snowflake, GuildMember>; public readonly full: boolean; public readonly joinable: boolean; public bitrate: number; public nsfw: boolean; public rtcRegion: string | null; public rateLimitPerUser: number | null; public userLimit: number; public videoQualityMode: VideoQualityMode | null; public createInvite(options?: CreateInviteOptions): Promise<Invite>; public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this>; public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>; public setBitrate(bitrate: number, reason?: string): Promise<VoiceChannel>; public setUserLimit(userLimit: number, reason?: string): Promise<VoiceChannel>; public setVideoQualityMode(videoQualityMode: VideoQualityMode | number, reason?: string): Promise<VoiceChannel>; } export class BaseMessageComponent { protected constructor(data?: BaseMessageComponent | BaseMessageComponentOptions); public type: MessageComponentType | null; private static create(data: MessageComponentOptions, client?: Client | WebhookClient): MessageComponent | undefined; private static resolveType(type: MessageComponentTypeResolvable): MessageComponentType; } export class BitField<S extends string, N extends number | bigint = number> { public constructor(bits?: BitFieldResolvable<S, N>); public bitfield: N; public add(...bits: BitFieldResolvable<S, N>[]): BitField<S, N>; public any(bit: BitFieldResolvable<S, N>): boolean; public equals(bit: BitFieldResolvable<S, N>): boolean; public freeze(): Readonly<BitField<S, N>>; public has(bit: BitFieldResolvable<S, N>): boolean; public missing(bits: BitFieldResolvable<S, N>, ...hasParams: readonly unknown[]): S[]; public remove(...bits: BitFieldResolvable<S, N>[]): BitField<S, N>; public serialize(...hasParams: readonly unknown[]): Record<S, boolean>; public toArray(...hasParams: readonly unknown[]): S[]; public toJSON(): N extends number ? number : string; public valueOf(): N; public [Symbol.iterator](): IterableIterator<S>; public static FLAGS: Record<string, number | bigint>; public static resolve(bit?: BitFieldResolvable<string, number | bigint>): number | bigint; } export class ButtonInteraction<Cached extends CacheType = CacheType> extends MessageComponentInteraction<Cached> { private constructor(client: Client, data: RawMessageButtonInteractionData); public readonly component: CacheTypeReducer< Cached, MessageButton, APIButtonComponent, MessageButton | APIButtonComponent, MessageButton | APIButtonComponent >; public componentType: 'BUTTON'; public inGuild(): this is ButtonInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ButtonInteraction<'cached'>; public inRawGuild(): this is ButtonInteraction<'raw'>; } export type KeyedEnum<K, T> = { [Key in keyof K]: T | string; }; export type EnumValueMapped<E extends KeyedEnum<T, number>, T extends Partial<Record<keyof E, unknown>>> = T & { [Key in keyof T as E[Key]]: T[Key]; }; export type MappedChannelCategoryTypes = EnumValueMapped< typeof ChannelTypes, { GUILD_NEWS: NewsChannel; GUILD_VOICE: VoiceChannel; GUILD_TEXT: TextChannel; GUILD_STORE: StoreChannel; GUILD_STAGE_VOICE: StageChannel; GUILD_FORUM: ForumChannel; } >; export type CategoryChannelTypes = ExcludeEnum< typeof ChannelTypes, | 'DM' | 'GROUP_DM' | 'UNKNOWN' | 'GUILD_PUBLIC_THREAD' | 'GUILD_NEWS_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_CATEGORY' | 'GUILD_DIRECTORY' >; export class CategoryChannel extends GuildChannel { public readonly children: Collection<Snowflake, Exclude<NonThreadGuildBasedChannel, CategoryChannel>>; public static parent: null; public parentId: null; public type: 'GUILD_CATEGORY'; public createChannel<T extends Exclude<CategoryChannelTypes, 'GUILD_STORE' | ChannelTypes.GUILD_STORE>>( name: string, options: CategoryCreateChannelOptions & { type: T }, ): Promise<MappedChannelCategoryTypes[T]>; /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/6309018858647) for more information */ public createChannel( name: string, options: CategoryCreateChannelOptions & { type: 'GUILD_STORE' | ChannelTypes.GUILD_STORE }, ): Promise<StoreChannel>; public createChannel(name: string, options?: CategoryCreateChannelOptions): Promise<TextChannel>; } export type CategoryChannelResolvable = Snowflake | CategoryChannel; export abstract class Channel extends Base { public constructor(client: Client, data?: RawChannelData, immediatePatch?: boolean); public readonly createdAt: Date | null; public readonly createdTimestamp: number | null; /** @deprecated This will be removed in the next major version, see https://github.com/discordjs/discord.js/issues/7091 */ public deleted: boolean; public id: Snowflake; public readonly partial: false; public type: keyof typeof ChannelTypes; public flags: Readonly<ChannelFlags> | null; public delete(): Promise<this>; public fetch(force?: boolean): Promise<this>; public isText(): this is TextBasedChannel; public isVoice(): this is BaseGuildVoiceChannel; public isThread(): this is ThreadChannel; public isDirectory(): this is DirectoryChannel; public toString(): ChannelMention; } export type If<T extends boolean, A, B = null> = T extends true ? A : T extends false ? B : A | B; export class Client<Ready extends boolean = boolean> extends BaseClient { public constructor(options?: ClientOptions); private actions: unknown; private presence: ClientPresence; private _eval(script: string): unknown; private _validateOptions(options: ClientOptions): void; public channels: ChannelManager; public readonly emojis: BaseGuildEmojiManager; public guilds: GuildManager; public options: ClientOptions; public readyAt: If<Ready, Date>; public readonly readyTimestamp: If<Ready, number>; public sweepers: Sweepers; public shard: ShardClientUtil | null; public token: If<Ready, string, string | null>; public uptime: If<Ready, number>; public user: If<Ready, ClientUser>; public users: UserManager; public voice: ClientVoiceManager; public ws: WebSocketManager; public notes: UserNoteManager; public relationships: RelationshipManager; public voiceStates: VoiceStateManager; public presences: PresenceManager; public billing: BillingManager; public settings: ClientUserSettingManager; public destroy(): void; public fetchGuildPreview(guild: GuildResolvable): Promise<GuildPreview>; public fetchInvite(invite: InviteResolvable, options?: ClientFetchInviteOptions): Promise<Invite>; public fetchGuildTemplate(template: GuildTemplateResolvable): Promise<GuildTemplate>; public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>; public fetchSticker(id: Snowflake): Promise<Sticker>; public fetchPremiumStickerPacks(): Promise<Collection<Snowflake, StickerPack>>; public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>; public fetchGuildWidget(guild: GuildResolvable): Promise<Widget>; public sleep(timeout: number): Promise<void>; public login(token?: string): Promise<string>; public QRLogin(): Promise<void>; public logout(): Promise<void>; public isReady(): this is Client<true>; /** @deprecated Use {@link Sweepers#sweepMessages} instead */ public sweepMessages(lifetime?: number): number; public toJSON(): unknown; public acceptInvite(invite: InviteResolvable): Promise<void>; public redeemNitro(nitro: string, channel?: TextChannelResolvable, paymentSourceId?: Snowflake): Promise<any>; public authorizeURL(url: string, options?: OAuth2AuthorizeOptions): Promise<any>; public on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaitable<void>): this; public on<S extends string | symbol>( event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaitable<void>, ): this; public once<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaitable<void>): this; public once<S extends string | symbol>( event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaitable<void>, ): this; public emit<K extends keyof ClientEvents>(event: K, ...args: ClientEvents[K]): boolean; public emit<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, ...args: unknown[]): boolean; public off<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaitable<void>): this; public off<S extends string | symbol>( event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaitable<void>, ): this; public removeAllListeners<K extends keyof ClientEvents>(event?: K): this; public removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof ClientEvents>): this; } export interface OAuth2AuthorizeOptions { guild_id?: Snowflake; permissions?: PermissionResolvable; authorize?: boolean; code?: string; webhook_channel_id?: Snowflake; } export class ClientPresence extends Presence { private constructor(client: Client, data: RawPresenceData); private _parse(data: PresenceData): RawPresenceData; public set(presence: PresenceData): ClientPresence; } export class ClientUser extends User { public mfaEnabled: boolean; public readonly presence: ClientPresence; public verified: boolean; public edit(data: ClientUserEditData): Promise<this>; public setActivity(options?: ActivityOptions): ClientPresence; public setActivity(name: string, options?: Omit<ActivityOptions, 'name'>): ClientPresence; public setAFK(afk?: boolean, shardId?: number | number[]): ClientPresence; public setAvatar(avatar: BufferResolvable | Base64Resolvable | null): Promise<this>; public setPresence(data: PresenceData): ClientPresence; public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence; public setUsername(username: string, password: string): Promise<this>; public purchasedFlags: PurchasedFlags; public premiumUsageFlags: PremiumUsageFlags; public phone: string | null; public nsfwAllowed?: boolean; public email: string | null; public bio?: string; public pronouns?: string; public premiumType: number; public setBanner(banner: BufferResolvable | Base64Resolvable | null): Promise<this>; public setHypeSquad( hypesquad: 0 | 1 | 2 | 3 | 'LEAVE' | 'HOUSE_BRAVERY' | 'HOUSE_BRILLIANCE' | 'HOUSE_BALANCE', ): Promise<void>; public setAccentColor(color: ColorResolvable): Promise<this>; public setAboutMe(bio: string | null): Promise<this>; public createFriendInvite(): Promise<Invite>; public getAllFriendInvites(): Promise<Collection<string, Invite>>; public revokeAllFriendInvites(): Promise<void>; public setSamsungActivity(packageName: string, type: 'START' | 'UPDATE' | 'STOP'): Promise<this>; public stopRinging(channel: ChannelResolvable): Promise<void>; public fetchBurstCredit(): Promise<number>; public setPronouns(pronouns?: string | null): Promise<this>; public setGlobalName(globalName?: string | null): Promise<this>; } export class Options extends null { private constructor(); public static defaultMakeCacheSettings: CacheWithLimitsOptions; public static defaultSweeperSettings: SweeperOptions; public static createDefault(): ClientOptions; public static cacheWithLimits(settings?: CacheWithLimitsOptions): CacheFactory; public static cacheEverything(): CacheFactory; } export class ClientVoiceManager { private constructor(client: Client); public readonly client: Client; public adapters: Map<Snowflake, InternalDiscordGatewayAdapterLibraryMethods>; } export { Collection } from '@discordjs/collection'; export interface CollectorEventTypes<K, V, F extends unknown[] = []> { collect: [V, ...F]; dispose: [V, ...F]; end: [collected: Collection<K, V>, reason: string]; } export type ChannelFlagsString = 'PINNED' | 'REQUIRE_TAG'; export class ChannelFlags extends BitField<ChannelFlagsString> { public static FLAGS: Record<ChannelFlagsString, number>; public static resolve(bit?: BitFieldResolvable<ChannelFlagsString, number>): number; } export abstract class Collector<K, V, F extends unknown[] = []> extends EventEmitter { protected constructor(client: Client, options?: CollectorOptions<[V, ...F]>); private _timeout: NodeJS.Timeout | null; private _idletimeout: NodeJS.Timeout | null; public readonly client: Client; public collected: Collection<K, V>; public ended: boolean; public abstract readonly endReason: string | null; public filter: CollectorFilter<[V, ...F]>; public readonly next: Promise<V>; public options: CollectorOptions<[V, ...F]>; public checkEnd(): boolean; public handleCollect(...args: unknown[]): Promise<void>; public handleDispose(...args: unknown[]): Promise<void>; public stop(reason?: string): void; public resetTimer(options?: CollectorResetTimerOptions): void; public [Symbol.asyncIterator](): AsyncIterableIterator<V>; public toJSON(): unknown; protected listener: (...args: any[]) => void; public abstract collect(...args: unknown[]): K | null | Promise<K | null>; public abstract dispose(...args: unknown[]): K | null; public on<EventKey extends keyof CollectorEventTypes<K, V, F>>( event: EventKey, listener: (...args: CollectorEventTypes<K, V, F>[EventKey]) => Awaitable<void>, ): this; public once<EventKey extends keyof CollectorEventTypes<K, V, F>>( event: EventKey, listener: (...args: CollectorEventTypes<K, V, F>[EventKey]) => Awaitable<void>, ): this; } export interface ApplicationCommandInteractionOptionResolver<Cached extends CacheType = CacheType> extends CommandInteractionOptionResolver<Cached> { getSubcommand(required?: true): string; getSubcommand(required: boolean): string | null; getSubcommandGroup(required?: true): string; getSubcommandGroup(required: boolean): string | null; getBoolean(name: string, required: true): boolean; getBoolean(name: string, required?: boolean): boolean | null; getChannel(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['channel']>; getChannel(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['channel']> | null; getString(name: string, required: true): string; getString(name: string, required?: boolean): string | null; getInteger(name: string, required: true): number; getInteger(name: string, required?: boolean): number | null; getNumber(name: string, required: true): number; getNumber(name: string, required?: boolean): number | null; getUser(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['user']>; getUser(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['user']> | null; getMember(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['member']>; getMember(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['member']> | null; getRole(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['role']>; getRole(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['role']> | null; getMentionable( name: string, required: true, ): NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']>; getMentionable( name: string, required?: boolean, ): NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']> | null; } export class CommandInteraction<Cached extends CacheType = CacheType> extends BaseCommandInteraction<Cached> { public options: Omit<CommandInteractionOptionResolver<Cached>, 'getMessage' | 'getFocused'>; public inGuild(): this is CommandInteraction<'raw' | 'cached'>; public inCachedGuild(): this is CommandInteraction<'cached'>; public inRawGuild(): this is CommandInteraction<'raw'>; public toString(): string; } export class AutocompleteInteraction<Cached extends CacheType = CacheType> extends Interaction<Cached> { public readonly command: ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null; public channelId: Snowflake; public commandId: Snowflake; public commandName: string; public responded: boolean; public options: Omit<CommandInteractionOptionResolver<Cached>, 'getMessage'>; public inGuild(): this is AutocompleteInteraction<'raw' | 'cached'>; public inCachedGuild(): this is AutocompleteInteraction<'cached'>; public inRawGuild(): this is AutocompleteInteraction<'raw'>; private transformOption(option: APIApplicationCommandOption): CommandInteractionOption; public respond(options: ApplicationCommandOptionChoiceData[]): Promise<void>; } export class CommandInteractionOptionResolver<Cached extends CacheType = CacheType> { private constructor(client: Client, options: CommandInteractionOption[], resolved: CommandInteractionResolvedData); public readonly client: Client; public readonly data: readonly CommandInteractionOption<Cached>[]; public readonly resolved: Readonly<CommandInteractionResolvedData<Cached>>; private _group: string | null; private _hoistedOptions: CommandInteractionOption<Cached>[]; private _subcommand: string | null; private _getTypedOption( name: string, type: ApplicationCommandOptionType, properties: (keyof ApplicationCommandOption)[], required: true, ): CommandInteractionOption<Cached>; private _getTypedOption( name: string, type: ApplicationCommandOptionType, properties: (keyof ApplicationCommandOption)[], required: boolean, ): CommandInteractionOption<Cached> | null; public get(name: string, required: true): CommandInteractionOption<Cached>; public get(name: string, required?: boolean): CommandInteractionOption<Cached> | null; public getSubcommand(required?: true): string; public getSubcommand(required: boolean): string | null; public getSubcommandGroup(required?: true): string; public getSubcommandGroup(required: boolean): string | null; public getBoolean(name: string, required: true): boolean; public getBoolean(name: string, required?: boolean): boolean | null; public getChannel(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['channel']>; public getChannel(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['channel']> | null; public getString(name: string, required: true): string; public getString(name: string, required?: boolean): string | null; public getInteger(name: string, required: true): number; public getInteger(name: string, required?: boolean): number | null; public getNumber(name: string, required: true): number; public getNumber(name: string, required?: boolean): number | null; public getUser(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['user']>; public getUser(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['user']> | null; public getMember(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['member']>; public getMember(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['member']> | null; public getRole(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['role']>; public getRole(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['role']> | null; public getMentionable( name: string, required: true, ): NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']>; public getMentionable( name: string, required?: boolean, ): NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']> | null; public getMessage(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['message']>; public getMessage(name: string, required?: boolean): NonNullable<CommandInteractionOption<Cached>['message']> | null; public getFocused(getFull: true): AutocompleteFocusedOption; public getFocused(getFull?: boolean): string; public getAttachment(name: string, required: true): NonNullable<CommandInteractionOption<Cached>['attachment']>; public getAttachment( name: string, required?: boolean, ): NonNullable<CommandInteractionOption<Cached>['attachment']> | null; } export class ContextMenuInteraction<Cached extends CacheType = CacheType> extends BaseCommandInteraction<Cached> { public options: Omit< CommandInteractionOptionResolver<Cached>, | 'getFocused' | 'getMentionable' | 'getRole' | 'getNumber' | 'getInteger' | 'getString' | 'getChannel' | 'getBoolean' | 'getSubcommandGroup' | 'getSubcommand' >; public targetId: Snowflake; public targetType: Exclude<ApplicationCommandType, 'CHAT_INPUT'>; public inGuild(): this is ContextMenuInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ContextMenuInteraction<'cached'>; public inRawGuild(): this is ContextMenuInteraction<'raw'>; private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption<Cached>[]; } export class DataResolver extends null { private constructor(); public static resolveBase64(data: Base64Resolvable): string; public static resolveCode(data: string, regx: RegExp): string; public static resolveFile(resource: BufferResolvable | Stream): Promise<Buffer | Stream>; public static resolveFileAsBuffer(resource: BufferResolvable | Stream): Promise<Buffer>; public static resolveImage(resource: BufferResolvable | Base64Resolvable): Promise<string | null>; public static resolveInviteCode(data: InviteResolvable): string; public static resolveGuildTemplateCode(data: GuildTemplateResolvable): string; } export class DiscordAPIError extends Error { private constructor(error: unknown, status: number, request: unknown); private static flattenErrors(obj: unknown, key: string): string[]; public code: number; public method: string; public path: string; public httpStatus: number; public requestData: HTTPErrorData; public retries: number; public captcha: Captcha | null; } export interface Captcha { captcha_key: string[]; captcha_sitekey: string; captcha_service: 'hcaptcha'; captcha_rqdata?: string; captcha_rqtoken?: string; } export class DMChannel extends TextBasedChannelMixin(Channel, [ 'fetchWebhooks', 'createWebhook', 'setRateLimitPerUser', 'setNSFW', ]) { private constructor(client: Client, data?: RawDMChannelData); public recipient: User; public type: 'DM'; public flags: Readonly<ChannelFlags>; public messageRequest?: boolean; public messageRequestTimestamp?: number; public fetch(force?: boolean): Promise<this>; public acceptMessageRequest(): Promise<this>; public cancelMessageRequest(): Promise<this>; public sync(): void; public ring(): Promise<void>; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; public readonly shard: WebSocketShard; public readonly voiceUsers: Collection<Snowflake, User>; } export class Emoji extends Base { protected constructor(client: Client, emoji: RawEmojiData); public animated: boolean | null; public readonly createdAt: Date | null; public readonly createdTimestamp: number | null; /** @deprecated This will be removed in the next major version, see https://github.com/discordjs/discord.js/issues/7091 */ public deleted: boolean; public id: Snowflake | null; public name: string | null; public readonly identifier: string; public readonly url: string | null; public toJSON(): unknown; public toString(): string; } export class Guild extends AnonymousGuild { private constructor(client: Client, data: RawGuildData); private _sortedRoles(): Collection<Snowflake, Role>; private _sortedChannels(channel: NonThreadGuildBasedChannel): Collection<Snowflake, NonThreadGuildBasedChannel>; public readonly afkChannel: VoiceChannel | null; public afkChannelId: Snowflake | null; public afkTimeout: number; public applicationId: Snowflake | null; public maxVideoChannelUsers: number | null; public maxStageVideoChannelUsers: number | null; public approximateMemberCount: number | null; public approximatePresenceCount: number | null; public autoModerationRules: AutoModerationRuleManager; public available: boolean; public bans: GuildBanManager; public channels: GuildChannelManager; public defaultMessageNotifications: DefaultMessageNotificationLevel | number; /** @deprecated This will be removed in the next major version, see https://github.com/discordjs/discord.js/issues/7091 */ public deleted: boolean; public discoverySplash: string | null; public emojis: GuildEmojiManager; public explicitContentFilter: ExplicitContentFilterLevel; public invites: GuildInviteManager; public readonly joinedAt: Date; public joinedTimestamp: number; public large: boolean; public maximumMembers: number | null; public maximumPresences: number | null; /** @deprecated Use {@link GuildMemberManager.me} instead. */ public readonly me: GuildMember | null; public memberCount: number; public members: GuildMemberManager; public mfaLevel: MFALevel; public ownerId: Snowflake; public preferredLocale: string; public premiumProgressBarEnabled: boolean; public premiumTier: PremiumTier; public presences: PresenceManager; public readonly publicUpdatesChannel: TextChannel | null; public publicUpdatesChannelId: Snowflake | null; public roles: RoleManager; public readonly rulesChannel: TextChannel | null; public rulesChannelId: Snowflake | null; public readonly safetyAlertsChannel: TextChannel | null; public safetyAlertsChannelId: Snowflake | null; public scheduledEvents: GuildScheduledEventManager; public readonly shard: WebSocketShard; public shardId: number; public stageInstances: StageInstanceManager; public stickers: GuildStickerManager; public readonly systemChannel: TextChannel | null; public systemChannelFlags: Readonly<SystemChannelFlags>; public systemChannelId: Snowflake | null; public vanityURLUses: number | null; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; public readonly voiceStates: VoiceStateManager; public readonly widgetChannel: TextChannel | NewsChannel | VoiceBasedChannel | ForumChannel | null; public widgetChannelId: Snowflake | null; public widgetEnabled: boolean | null; public readonly maximumBitrate: number; public createTemplate(name: string, description?: string): Promise<GuildTemplate>; public delete(): Promise<Guild>; public discoverySplashURL(options?: StaticImageURLOptions): string | null; public edit(data: GuildEditData, reason?: string): Promise<Guild>; public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>; public equals(guild: Guild): boolean; public fetchAuditLogs<T extends GuildAuditLogsResolvable = 'ALL'>( options?: GuildAuditLogsFetchOptions<T>, ): Promise<GuildAuditLogs<T>>; public fetchIntegrations(): Pr