UNPKG

discord.js-selfbot-v13

Version:

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

1,253 lines (1,171 loc) 269 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 { VoiceConnection } from '@discordjs/voice'; 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, MessageActivityType, GatewayOpcodes, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, RESTPostAPIApplicationCommandsJSONBody, Snowflake, LocalizationMap, } 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, ChannelTypes, RelationshipTypes, localeSetting, stickerAnimationMode, DMScanLevel, DefaultMessageNotificationLevels, ExplicitContentFilterLevels, InteractionResponseTypes, InteractionTypes, InviteTargetType, MembershipStates, MessageButtonStyles, MessageComponentTypes, MessageTypes, ModalComponentTypes, MFALevels, NitroType as NitroTypes, HypeSquadType as HypeSquadTypes, localeSetting as localeSettings, NSFWLevels, OverwriteTypes, PremiumTiers, PrivacyLevels, StickerFormatTypes, StickerTypes, TextInputStyles, VerificationLevels, WebhookTypes, GuildScheduledEventEntityTypes, GuildScheduledEventStatuses, GuildScheduledEventPrivacyLevels, HypeSquadType, VideoQualityModes, SortOrderType, } from './enums'; import { RawActivityData, RawAnonymousGuildData, RawApplicationCommandData, RawApplicationData, RawBaseGuildData, RawChannelData, RawClientApplicationData, 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'; // @ts-ignore //#region Classes export class SessionManager extends CachedManager { constructor(client: Client, iterable?: Iterable<unknown>); public fetch(): Promise<SessionManager>; public logoutAllDevices(mfaCode?: string): Promise<undefined>; } export class Session extends Base { constructor(client: Client); public id?: string; public clientInfo?: SessionClientInfo; public readonly createdTimestamp: number; public readonly createdAt: Date; public logout(mfaCode?: string): Promise<undefined>; } export interface SessionClientInfo { location?: string; platform?: string; os?: string; } export class DiscordAuthWebsocket extends EventEmitter { constructor(options?: DiscordAuthWebsocketOptions); public fingerprint?: string; public heartbeatInterval?: number; public ws?: WebSocket; public token?: string; public realToken?: string; public user?: RawUserData; public readonly exprireTime: string; public connect(client?: Client): void; public destroy(): void; public generateQR(): void; public on(event: 'ready', listener: (fingerprint: string, authURL: string) => void): this; public on(event: 'finish', listener: (user: RawUserData, token: string) => void): this; public on(event: 'cancel' | 'pending', listener: (user: RawUserData) => void): this; public on(event: 'closed', listener: (token?: string) => void): this; public on(event: string, listener: (...args: any[]) => Awaitable<void>): this; } export interface DiscordAuthWebsocketOptions { debug: boolean; hiddenLog: boolean; autoLogin: boolean; failIfError: boolean; generateQR: boolean; userAgent?: string; wsProperties?: object; } // 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?: any): this; public setAssetsLargeText(text?: string): this; public setAssetsSmallImage(image?: any): 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 static getUUID(): string; public toJSON(): object; public toString(): string; } export interface ExternalAssets { url: string; external_asset_path: 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 created_at: Date; public flags: number; public secrets: { join: string; spectate: string; match: string; }; public session_id: 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 setAssetsLargeImage(image?: string): this; public setAssetsSmallImage(image?: string): this; public setSongId(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 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 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 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 invite(guildID: Snowflake, permissions?: PermissionResolvable, captcha?: string): Promise<undefined>; public iconURL(options?: StaticImageURLOptions): string | null; public toJSON(): unknown; public toString(): string | null; } export interface Tester { state: number; user: User; } export interface ApplicationEditData { name?: string; description?: string; icon?: BufferResolvable | Base64Resolvable; cover?: BufferResolvable | Base64Resolvable; botPublic?: boolean; botRequireCodeGrant?: boolean; TermsOfService?: string; PrivacyPolicy?: string; flags?: number; redirectURIs?: string[]; tags?: string[]; } export class DeveloperPortalApplication extends Base { private constructor(client: Client, data: object); public botPublic: boolean | null; public botRequireCodeGrant: boolean | null; public commands: ApplicationCommandManager; public cover: string | null; public flags: Readonly<ApplicationFlags>; public tags: string[]; public installParams: ClientApplicationInstallParams | null; public customInstallURL: string | null; public owner: User | Team | null; public readonly partial: boolean; public rpcOrigins: string[]; public readonly createdAt: Date; public readonly createdTimestamp: number; public description: string | null; public icon: string | null; public id: Snowflake; public name: string | null; public redirectURIs: string[]; public interactionEndpointURL: string | null; public publicKey: string; public testers: Collection<Snowflake, Tester>; public TermsOfService: string | null; public PrivacyPolicy: string | null; public fetch(): Promise<ClientApplication>; 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; public fetchTesters(): Promise<this>; public addTester(username: string, discriminator: string): Promise<DeveloperPortalApplication>; public deleteTester(user: UserResolvable): Promise<DeveloperPortalApplication>; public edit(data: ApplicationEditData): Promise<DeveloperPortalApplication>; public createBot(): Promise<DeveloperPortalApplication>; public resetClientSecret(MFACode?: number): Promise<string>; public resetBotToken(MFACode?: number): Promise<string>; public delete(MFACode?: number): Promise<undefined>; public addAsset(image: BufferResolvable | Base64Resolvable, name: string): Promise<ApplicationAsset>; public deleteAsset(id: string): Promise<undefined>; } export class DeveloperPortalManager extends BaseManager { constructor(client: Client); public applications: Collection<Snowflake, DeveloperPortalApplication>; public teams: Collection<Snowflake, Team>; public fetch(): Promise<DeveloperPortalManager>; public createApplication(name: string, teamId?: Team | Snowflake): Promise<DeveloperPortalApplication>; public deleteApplication(id: Snowflake, MFACode?: number): Promise<undefined>; } export class ApplicationCommand<PermissionsFetchType = {}> extends Base { private constructor(client: Client, data: RawApplicationCommandData); public applicationId: Snowflake; public readonly createdAt: Date; public readonly createdTimestamp: number; /** @deprecated Use {@link defaultMemberPermissions} and {@link dmPermission} instead. */ public defaultPermission: boolean; public description: string; public descriptionLocalizations: LocalizationMap | null; public descriptionLocalized: string | null; public readonly 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; // Add public static sendSlashCommand( message: Message, subCommandArray?: string[], options?: any[], ): Promise<InteractionResponse>; public static sendContextMenu(message: Message): Promise<InteractionResponse>; } export type ApplicationResolvable = Application | Activity | 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 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 GuildChannel { public constructor(guild: Guild, data?: RawGuildChannelData); public readonly members: Collection<Snowflake, GuildMember>; public readonly full: boolean; public readonly joinable: boolean; public rtcRegion: string | null; public bitrate: number; public userLimit: number; public createInvite(options?: CreateInviteOptions): Promise<Invite>; public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this>; public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>; } 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 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 interface remoteAuthConfrim { yes(): Promise<undefined>; no(): Promise<undefined>; } export class Client<Ready extends boolean = boolean> extends BaseClient { public constructor(options?: ClientOptions); /* Bug report by Mavri#0001 [721347809667973141] */ private actions: unknown; private presence: ClientPresence; private _eval(script: string): unknown; private _validateOptions(options: ClientOptions): void; private autoRedeemNitro(message: Message): object; public application: If<Ready, ClientApplication>; // Added public settings: ClientSettingManager; public relationships: RelationshipManager; public updateCookie(): Promise<void>; public readonly callVoice?: VoiceConnection; public voiceStates: VoiceStateManager; // End 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 password: string | null; public readonly sessionId: string | null; public destroy(): void; public logout(): Promise<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 redeemNitro(code: string, channel?: TextChannelResolvable, failIfNotExists?: boolean): object; public generateInvite(options?: InviteGenerationOptions): string; public login(token?: string): Promise<string>; public normalLogin(username: string, password?: string, mfaCode?: string): Promise<string>; public QRLogin(debug?: boolean): DiscordAuthWebsocket; public remoteAuth(url: string, forceAccept?: boolean): Promise<remoteAuthConfrim | undefined>; public createToken(): Promise<string>; public checkUpdate(): Promise<this>; public isReady(): this is Client<true>; /** @deprecated Use {@link Sweepers#sweepMessages} instead */ public sweepMessages(lifetime?: number): number; public customStatusAuto(client?: this): undefined; public authorizeURL(url: string, options?: object): Promise<boolean>; public sleep(milliseconds: number): Promise<void> | null; public toJSON(): unknown; 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 class ClientApplication extends Application { private constructor(client: Client, data: RawClientApplicationData); public botPublic: boolean | null; public popularCommands: Collection<Snowflake, ApplicationCommand> | undefined; public botRequireCodeGrant: boolean | null; public commands: ApplicationCommandManager; public cover: string | null; public flags: Readonly<ApplicationFlags>; 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<ClientApplication>; } 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 notes: Collection<Snowflake, string>; public friendNicknames: Collection<Snowflake, string>; public setThemeColors(primary?: ColorResolvable, accent?: ColorResolvable): ClientUser; public edit(data: ClientUserEditData): Promise<this>; public setActivity(options?: ActivityOptions): ClientPresence; public setActivity(name: string, options?: ActivityOptions): ClientPresence; public setAFK(afk?: boolean, shardId?: number | number[]): ClientPresence; public setAvatar(avatar: BufferResolvable | Base64Resolvable | null): Promise<this>; public setBanner(banner: 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 setHypeSquad(type: HypeSquadType): Promise<void>; public setAccentColor(color: ColorResolvable): Promise<this>; public setDiscriminator(discriminator: string, password: string): Promise<this>; public setAboutMe(bio: string | null): Promise<this>; public setEmail(email: string, password: string): Promise<this>; public setPassword(oldPassword: string, newPassword: string): Promise<this>; public disableAccount(password: string): Promise<this>; public deleteAccount(password: string): Promise<this>; public setDeaf(status: boolean): Promise<boolean>; public setMute(status: boolean): Promise<boolean>; public getInvite(options?: CreateInviteOptions): Promise<Invite>; public getMentions( limit?: number, mentionRoles?: boolean, mentionEveryone?: boolean, ): Promise<Collection<Snowflake, Message>>; /** * Nitro Status * `0`: None * `1`: Classic * `2`: Boost * @external https://discord.com/developers/docs/resources/user#user-object-premium-types */ public readonly nitroType: NitroType; public readonly phoneNumber: string; public readonly nsfwAllowed: boolean; public readonly emailAddress: string; } type NitroType = 'NONE' | 'NITRO_CLASSIC' | 'NITRO_BOOST' | 'NITRO_BASIC'; 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 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 interface Captcha { captcha_key: string[]; captcha_service: string; captcha_sitekey: string; captcha_rqdata?: string; captcha_rqtoken?: string; } export class DiscordAPIError extends Error { private constructor(error: unknown, status: number, request: unknown); private static flattenErrors(obj: unknown, key: string): string[]; public captcha?: Captcha; public code: number; public method: string; public path: string; public httpStatus: number; public requestData: HTTPErrorData; } export class DMChannel extends TextBasedChannelMixin(Channel, [ 'bulkDelete', 'fetchWebhooks', 'createWebhook', 'setRateLimitPerUser', 'setNSFW', ]) { private constructor(client: Client, data?: RawDMChannelData); public recipient: User; public type: 'DM'; public flags: Readonly<ChannelFlags>; public fetch(force?: boolean): Promise<this>; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; public call(options?: CallOptions): Promise<VoiceConnection>; public sync(): undefined; public readonly shard: WebSocketShard; public readonly voiceUsers: Collection<Snowflake, User>; public readonly voiceConnection?: VoiceConnection; } export interface CallOptions { selfDeaf?: boolean; selfMute?: boolean; ring?: boolean; } 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, NonThreadGuildBa