UNPKG

discord.js

Version:

A powerful library for interacting with the Discord API

1,260 lines (1,161 loc) • 290 kB
import { ActionRowBuilder as BuilderActionRow, MessageActionRowComponentBuilder, ButtonBuilder as BuilderButtonComponent, EmbedBuilder as BuildersEmbed, ChannelSelectMenuBuilder as BuilderChannelSelectMenuComponent, MentionableSelectMenuBuilder as BuilderMentionableSelectMenuComponent, RoleSelectMenuBuilder as BuilderRoleSelectMenuComponent, StringSelectMenuBuilder as BuilderStringSelectMenuComponent, UserSelectMenuBuilder as BuilderUserSelectMenuComponent, TextInputBuilder as BuilderTextInputComponent, SelectMenuOptionBuilder as BuildersSelectMenuOption, ModalActionRowComponentBuilder, ModalBuilder as BuildersModal, AnyComponentBuilder, type RestOrArray, ApplicationCommandOptionAllowedChannelTypes, } from '@discordjs/builders'; import { blockQuote, bold, channelMention, codeBlock, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, italic, quote, roleMention, spoiler, strikethrough, time, TimestampStyles, underscore, userMention, } from '@discordjs/formatters'; import { Awaitable, JSONEncodable } from '@discordjs/util'; import { Collection, ReadonlyCollection } from '@discordjs/collection'; import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest'; import { WebSocketManager as WSWebSocketManager, IShardingStrategy, IIdentifyThrottler, SessionInfo, } from '@discordjs/ws'; import { APIActionRowComponent, APIApplicationCommandInteractionData, APIApplicationCommandOption, APIAuditLogChange, APIButtonComponent, APIEmbed, APIEmoji, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessage, APIMessageComponent, APIOverwrite, APIPartialChannel, APIPartialEmoji, APIPartialGuild, APIRole, APISelectMenuComponent, APITemplateSerializedSourceGuild, APIUser, ButtonStyle, ChannelType, ComponentType, GatewayDispatchEvents, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, GuildFeature, GuildMFALevel, GuildNSFWLevel, GuildPremiumTier, GuildVerificationLevel, Locale, InteractionType, InviteTargetType, MessageType, OAuth2Scopes, RESTPostAPIApplicationCommandsJSONBody, Snowflake, StageInstancePrivacyLevel, StickerFormatType, StickerType, TeamMemberMembershipState, WebhookType, OverwriteType, GuildExplicitContentFilter, GuildDefaultMessageNotifications, ApplicationCommandPermissionType, ApplicationCommandOptionType, ApplicationCommandType, ActivityType, GuildScheduledEventEntityType, GuildScheduledEventPrivacyLevel, GuildScheduledEventStatus, IntegrationExpireBehavior, ApplicationFlags, PermissionFlagsBits, ThreadMemberFlags, UserFlags, MessageFlags, GuildSystemChannelFlags, GatewayIntentBits, ActivityFlags, AuditLogEvent, APIMessageComponentEmoji, EmbedType, APIActionRowComponentTypes, APIModalInteractionResponseCallbackData, APIModalSubmitInteraction, APIMessageActionRowComponent, TextInputStyle, APITextInputComponent, APIModalActionRowComponent, APIModalComponent, APISelectMenuOption, APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, VideoQualityMode, LocalizationMap, MessageActivityType, APIAttachment, APIChannel, ThreadAutoArchiveDuration, FormattingPatterns, APIEmbedProvider, AuditLogOptionsType, TextChannelType, ChannelFlags, SortOrderType, APIMessageStringSelectInteractionData, APIMessageUserSelectInteractionData, APIStringSelectComponent, APIUserSelectComponent, APIRoleSelectComponent, APIMentionableSelectComponent, APIChannelSelectComponent, APIGuildMember, APIMessageRoleSelectInteractionData, APIMessageMentionableSelectInteractionData, APIMessageChannelSelectInteractionData, AutoModerationRuleKeywordPresetType, AutoModerationActionType, AutoModerationRuleEventType, AutoModerationRuleTriggerType, AuditLogRuleTriggerType, GatewayAutoModerationActionExecutionDispatchData, APIAutoModerationRule, ForumLayoutType, ApplicationRoleConnectionMetadataType, APIApplicationRoleConnectionMetadata, ImageFormat, GuildMemberFlags, RESTGetAPIGuildThreadsResult, RESTGetAPIGuildOnboardingResult, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, GuildOnboardingPromptType, AttachmentFlags, RoleFlags, TeamMemberRole, GuildWidgetStyle, GuildOnboardingMode, APISKU, SKUFlags, SKUType, APIEntitlement, EntitlementType, ApplicationIntegrationType, InteractionContextType, APIPoll, PollLayoutType, APIPollAnswer, APISelectMenuDefaultValue, SelectMenuDefaultValueType, InviteType, ReactionType, APIAuthorizingIntegrationOwnersMap, MessageReferenceType, GuildScheduledEventRecurrenceRuleWeekday, GuildScheduledEventRecurrenceRuleMonth, GuildScheduledEventRecurrenceRuleFrequency, APISubscription, SubscriptionStatus, ApplicationWebhookEventStatus, ApplicationWebhookEventType, GatewaySendPayload, GatewayDispatchPayload, RESTPostAPIInteractionCallbackWithResponseResult, RESTAPIInteractionCallbackObject, RESTAPIInteractionCallbackResourceObject, InteractionResponseType, RESTAPIInteractionCallbackActivityInstanceResource, VoiceChannelEffectSendAnimationType, GatewayVoiceChannelEffectSendDispatchData, APIChatInputApplicationCommandInteractionData, APIContextMenuInteractionData, } from 'discord-api-types/v10'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; import { Stream } from 'node:stream'; import { MessagePort, Worker } from 'node:worker_threads'; import { RawActivityData, RawAnonymousGuildData, RawApplicationCommandData, RawApplicationData, RawApplicationEmojiData, RawBaseGuildData, RawChannelData, RawClientApplicationData, RawDMChannelData, RawEmojiData, RawGuildAuditLogData, RawGuildAuditLogEntryData, RawGuildBanData, RawGuildChannelData, RawGuildData, RawGuildEmojiData, RawGuildMemberData, RawGuildPreviewData, RawGuildScheduledEventData, RawGuildTemplateData, RawIntegrationApplicationData, RawIntegrationData, RawInteractionData, RawInviteData, RawInviteGuildData, RawInviteStageInstance, RawMessageButtonInteractionData, RawMessageComponentInteractionData, RawMessageData, RawMessagePayloadData, RawMessageReactionData, RawOAuth2GuildData, RawPartialGroupDMChannelData, RawPartialMessageData, RawPermissionOverwriteData, RawPresenceData, RawReactionEmojiData, RawRichPresenceAssets, RawRoleData, RawStageInstanceData, RawStickerData, RawStickerPackData, RawTeamData, RawTeamMemberData, RawThreadChannelData, RawThreadMemberData, RawTypingData, RawUserData, RawVoiceRegionData, RawVoiceStateData, RawWebhookData, RawWelcomeChannelData, RawWelcomeScreenData, RawWidgetData, RawWidgetMemberData, } from './rawDataTypes.js'; //#region Classes 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 get createdAt(): Date; public createdTimestamp: number; public details: string | null; public emoji: Emoji | null; public flags: Readonly<ActivityFlagsBitField>; public name: string; public party: { id: string | null; size: [number, number]; } | 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; public toString(): string; } export type ActivityFlagsString = keyof typeof ActivityFlags; export interface BaseComponentData { type: ComponentType; } export type MessageActionRowComponentData = | JSONEncodable<APIMessageActionRowComponent> | ButtonComponentData | StringSelectMenuComponentData | UserSelectMenuComponentData | RoleSelectMenuComponentData | MentionableSelectMenuComponentData | ChannelSelectMenuComponentData; export type ModalActionRowComponentData = JSONEncodable<APIModalActionRowComponent> | TextInputComponentData; export type ActionRowComponentData = MessageActionRowComponentData | ModalActionRowComponentData; export type ActionRowComponent = MessageActionRowComponent | ModalActionRowComponent; export interface ActionRowData<ComponentType extends JSONEncodable<APIActionRowComponentTypes> | ActionRowComponentData> extends BaseComponentData { components: readonly ComponentType[]; } export class ActionRowBuilder< ComponentType extends AnyComponentBuilder = AnyComponentBuilder, > extends BuilderActionRow<ComponentType> { public constructor( data?: Partial< | ActionRowData<ActionRowComponentData | JSONEncodable<APIActionRowComponentTypes>> | APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent> >, ); public static from<ComponentType extends AnyComponentBuilder = AnyComponentBuilder>( other: | JSONEncodable<APIActionRowComponent<ReturnType<ComponentType['toJSON']>>> | APIActionRowComponent<ReturnType<ComponentType['toJSON']>>, ): ActionRowBuilder<ComponentType>; } export type MessageActionRowComponent = | ButtonComponent | StringSelectMenuComponent | UserSelectMenuComponent | RoleSelectMenuComponent | MentionableSelectMenuComponent | ChannelSelectMenuComponent; export type ModalActionRowComponent = TextInputComponent; export class ActionRow<ComponentType extends MessageActionRowComponent | ModalActionRowComponent> extends Component< APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent> > { private constructor(data: APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>); public readonly components: ComponentType[]; public toJSON(): APIActionRowComponent<ReturnType<ComponentType['toJSON']>>; } export class ActivityFlagsBitField extends BitField<ActivityFlagsString> { public static Flags: typeof ActivityFlags; public static resolve(bit?: BitFieldResolvable<ActivityFlagsString, number>): number; } export abstract class AnonymousGuild extends BaseGuild { protected constructor(client: Client<true>, data: RawAnonymousGuildData, immediatePatch?: boolean); public banner: string | null; public description: string | null; public nsfwLevel: GuildNSFWLevel; public premiumSubscriptionCount: number | null; public splash: string | null; public vanityURLCode: string | null; public verificationLevel: GuildVerificationLevel; public bannerURL(options?: ImageURLOptions): string | null; public splashURL(options?: ImageURLOptions): string | null; } export class AutoModerationActionExecution { private constructor(data: GatewayAutoModerationActionExecutionDispatchData, guild: Guild); public guild: Guild; public action: AutoModerationAction; public ruleId: Snowflake; public ruleTriggerType: AutoModerationRuleTriggerType; public get user(): User | null; public userId: Snowflake; public get channel(): GuildTextBasedChannel | ForumChannel | MediaChannel | null; public channelId: Snowflake | null; public get member(): GuildMember | null; public messageId: Snowflake | null; public alertSystemMessageId: Snowflake | null; public content: string; public matchedKeyword: string | null; public matchedContent: string | null; public get autoModerationRule(): AutoModerationRule | null; } export class AutoModerationRule extends Base { private constructor(client: Client<true>, data: APIAutoModerationRule, guild: Guild); public id: Snowflake; public guild: Guild; public name: string; public creatorId: Snowflake; public eventType: AutoModerationRuleEventType; public triggerType: AutoModerationRuleTriggerType; public triggerMetadata: AutoModerationTriggerMetadata; public actions: AutoModerationAction[]; public enabled: boolean; public exemptRoles: Collection<Snowflake, Role>; public exemptChannels: Collection<Snowflake, GuildBasedChannel>; public edit(options: AutoModerationRuleEditOptions): Promise<AutoModerationRule>; public delete(reason?: string): Promise<void>; public setName(name: string, reason?: string): Promise<AutoModerationRule>; public setEventType(eventType: AutoModerationRuleEventType, reason?: string): Promise<AutoModerationRule>; public setKeywordFilter(keywordFilter: readonly string[], reason?: string): Promise<AutoModerationRule>; public setRegexPatterns(regexPatterns: readonly string[], reason?: string): Promise<AutoModerationRule>; public setPresets( presets: readonly AutoModerationRuleKeywordPresetType[], reason?: string, ): Promise<AutoModerationRule>; public setAllowList(allowList: readonly string[], reason?: string): Promise<AutoModerationRule>; public setMentionTotalLimit(mentionTotalLimit: number, reason?: string): Promise<AutoModerationRule>; public setMentionRaidProtectionEnabled( mentionRaidProtectionEnabled: boolean, reason?: string, ): Promise<AutoModerationRule>; public setActions(actions: readonly AutoModerationActionOptions[], reason?: string): Promise<AutoModerationRule>; public setEnabled(enabled?: boolean, reason?: string): Promise<AutoModerationRule>; public setExemptRoles( roles: ReadonlyCollection<Snowflake, Role> | readonly RoleResolvable[], reason?: string, ): Promise<AutoModerationRule>; public setExemptChannels( channels: ReadonlyCollection<Snowflake, GuildBasedChannel> | readonly GuildChannelResolvable[], reason?: string, ): Promise<AutoModerationRule>; } export abstract class Application extends Base { protected constructor(client: Client<true>, data: RawApplicationData); public get createdAt(): Date; public get createdTimestamp(): number; public description: string | null; public icon: string | null; public id: Snowflake; public name: string | null; public termsOfServiceURL: string | null; public privacyPolicyURL: string | null; public rpcOrigins: string[]; public cover: string | null; public verifyKey: string | null; public coverURL(options?: ImageURLOptions): string | null; public iconURL(options?: ImageURLOptions): string | null; public toJSON(): unknown; public toString(): string | null; } export class ApplicationCommand<PermissionsFetchType = {}> extends Base { private constructor(client: Client<true>, data: RawApplicationCommandData, guild?: Guild, guildId?: Snowflake); public applicationId: Snowflake; public contexts: InteractionContextType[] | null; public get createdAt(): Date; public get createdTimestamp(): number; public defaultMemberPermissions: Readonly<PermissionsBitField> | null; public description: string; public descriptionLocalizations: LocalizationMap | null; public descriptionLocalized: string | null; /** @deprecated Use {@link ApplicationCommand.contexts} instead */ public dmPermission: boolean | null; public guild: Guild | null; public guildId: Snowflake | null; public get manager(): ApplicationCommandManager; public id: Snowflake; public integrationTypes: ApplicationIntegrationType[] | null; public name: string; public nameLocalizations: LocalizationMap | null; public nameLocalized: string | null; public options: (ApplicationCommandOption & { nameLocalized?: string; descriptionLocalized?: string })[]; public permissions: ApplicationCommandPermissionsManager< PermissionsFetchType, PermissionsFetchType, Guild | null, Snowflake >; public type: ApplicationCommandType; public version: Snowflake; public nsfw: boolean; 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>>; public setDefaultMemberPermissions( defaultMemberPermissions: PermissionResolvable | null, ): Promise<ApplicationCommand<PermissionsFetchType>>; public setDMPermission(dmPermission?: boolean): Promise<ApplicationCommand<PermissionsFetchType>>; public setOptions( options: readonly ApplicationCommandOptionData[], ): Promise<ApplicationCommand<PermissionsFetchType>>; public equals( command: ApplicationCommand | ApplicationCommandData | RawApplicationCommandData, enforceOptionOrder?: boolean, ): boolean; public static optionsEqual( existing: readonly ApplicationCommandOption[], options: | readonly ApplicationCommandOption[] | readonly ApplicationCommandOptionData[] | readonly 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: ApplicationRoleConnectionMetadataType; } export type ApplicationResolvable = Application | Activity | Snowflake; export class ApplicationFlagsBitField extends BitField<ApplicationFlagsString> { public static Flags: typeof ApplicationFlags; public static resolve(bit?: BitFieldResolvable<ApplicationFlagsString, number>): number; } export type ApplicationFlagsResolvable = BitFieldResolvable<ApplicationFlagsString, number>; export type AutoModerationRuleResolvable = AutoModerationRule | Snowflake; export abstract class Base { public constructor(client: Client<true>); public readonly client: Client<true>; public toJSON(...props: Record<string, boolean | string>[]): unknown; public valueOf(): string; } export class BaseClient extends EventEmitter implements AsyncDisposable { public constructor(options?: ClientOptions | WebhookClientOptions); private decrementMaxListeners(): void; private incrementMaxListeners(): void; public options: ClientOptions | WebhookClientOptions; public rest: REST; public destroy(): void; public toJSON(...props: Record<string, boolean | string>[]): unknown; public [Symbol.asyncDispose](): Promise<void>; } export type GuildCacheMessage<Cached extends CacheType> = CacheTypeReducer< Cached, Message<true>, APIMessage, Message | APIMessage, Message | APIMessage >; export type BooleanCache<Cached extends CacheType> = Cached extends 'cached' ? true : false; export abstract class CommandInteraction<Cached extends CacheType = CacheType> extends BaseInteraction<Cached> { public type: InteractionType.ApplicationCommand; public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null; public options: Omit< CommandInteractionOptionResolver<Cached>, | 'getMessage' | 'getFocused' | 'getMentionable' | 'getRole' | 'getUser' | 'getMember' | 'getAttachment' | 'getNumber' | 'getInteger' | 'getString' | 'getChannel' | 'getBoolean' | 'getSubcommandGroup' | 'getSubcommand' >; public channelId: Snowflake; public commandId: Snowflake; public commandName: string; public commandType: ApplicationCommandType; public commandGuildId: Snowflake | null; public deferred: boolean; public ephemeral: boolean | null; public replied: boolean; public webhook: InteractionWebhook; public inGuild(): this is CommandInteraction<'raw' | 'cached'>; public inCachedGuild(): this is CommandInteraction<'cached'>; public inRawGuild(): this is CommandInteraction<'raw'>; public deferReply( options: InteractionDeferReplyOptions & { withResponse: true }, ): Promise<InteractionCallbackResponse>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public deferReply( options: InteractionDeferReplyOptions & { fetchReply: true }, ): Promise<Message<BooleanCache<Cached>>>; public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>; public deleteReply(message?: MessageResolvable | '@original'): Promise<void>; public editReply( options: string | MessagePayload | InteractionEditReplyOptions, ): Promise<Message<BooleanCache<Cached>>>; public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>; public reply(options: InteractionReplyOptions & { withResponse: true }): Promise<InteractionCallbackResponse>; /** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */ public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>; public reply( options: string | MessagePayload | InteractionReplyOptions, ): Promise<InteractionResponse<BooleanCache<Cached>>>; public showModal( modal: | JSONEncodable<APIModalInteractionResponseCallbackData> | ModalComponentData | APIModalInteractionResponseCallbackData, options: ShowModalOptions & { withResponse: true }, ): Promise<InteractionCallbackResponse>; public showModal( modal: | JSONEncodable<APIModalInteractionResponseCallbackData> | ModalComponentData | APIModalInteractionResponseCallbackData, options?: ShowModalOptions & { withResponse: true }, ): Promise<InteractionCallbackResponse>; public showModal( modal: | JSONEncodable<APIModalInteractionResponseCallbackData> | ModalComponentData | APIModalInteractionResponseCallbackData, options?: ShowModalOptions, ): Promise<undefined>; /** @deprecated Sending a premium-style button is the new Discord behaviour. */ public sendPremiumRequired(): Promise<void>; public awaitModalSubmit( options: AwaitModalSubmitOptions<ModalSubmitInteraction>, ): Promise<ModalSubmitInteraction<Cached>>; private transformOption( option: APIApplicationCommandOption, resolved: Extract< APIApplicationCommandInteractionData, APIChatInputApplicationCommandInteractionData | APIContextMenuInteractionData >['resolved'], ): CommandInteractionOption<Cached>; } export class InteractionResponse<Cached extends boolean = boolean> { private constructor(interaction: Interaction, id?: Snowflake); public interaction: Interaction<WrapBooleanCache<Cached>>; public client: Client; public id: Snowflake; public get createdAt(): Date; public get createdTimestamp(): number; public awaitMessageComponent<ComponentType extends MessageComponentType>( options?: AwaitMessageCollectorOptionsParams<ComponentType, Cached>, ): Promise<MappedInteractionTypes<Cached>[ComponentType]>; public createMessageComponentCollector<ComponentType extends MessageComponentType>( options?: MessageCollectorOptionsParams<ComponentType, Cached>, ): InteractionCollector<MappedInteractionTypes<Cached>[ComponentType]>; public delete(): Promise<void>; public edit(options: string | MessagePayload | WebhookMessageEditOptions): Promise<Message>; public fetch(): Promise<Message>; } export abstract class BaseGuild extends Base { protected constructor(client: Client<true>, data: RawBaseGuildData); public get createdAt(): Date; public get createdTimestamp(): number; public features: `${GuildFeature}`[]; public icon: string | null; public id: Snowflake; public name: string; public get nameAcronym(): string; public get partnered(): boolean; public get verified(): boolean; public fetch(): Promise<Guild>; public iconURL(options?: ImageURLOptions): string | null; public toString(): string; } export class BaseGuildEmoji extends Emoji { protected constructor(client: Client<true>, data: RawGuildEmojiData, guild: Guild | GuildPreview); public imageURL(options?: BaseImageURLOptions): string; public get url(): string; public available: boolean | null; public get createdAt(): Date; public get createdTimestamp(): number; public guild: Guild | GuildPreview; public id: Snowflake; public managed: boolean | null; public requiresColons: boolean | null; } // tslint:disable-next-line no-empty-interface export interface BaseGuildTextChannel extends TextBasedChannelFields<true> {} export class BaseGuildTextChannel extends GuildChannel { protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client<true>, 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?: InviteCreateOptions): Promise<Invite>; public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>; public setDefaultAutoArchiveDuration( defaultAutoArchiveDuration: ThreadAutoArchiveDuration, reason?: string, ): Promise<this>; public setTopic(topic: string | null, reason?: string): Promise<this>; public setType(type: ChannelType.GuildText, reason?: string): Promise<TextChannel>; public setType(type: ChannelType.GuildAnnouncement, reason?: string): Promise<NewsChannel>; } // tslint:disable-next-line no-empty-interface export interface BaseGuildVoiceChannel extends Omit<TextBasedChannelFields<true>, 'lastPinTimestamp' | 'lastPinAt'> {} export class BaseGuildVoiceChannel extends GuildChannel { public constructor(guild: Guild, data?: RawGuildChannelData); public bitrate: number; public get full(): boolean; public get joinable(): boolean; public get members(): Collection<Snowflake, GuildMember>; public nsfw: boolean; public rateLimitPerUser: number | null; public rtcRegion: string | null; public userLimit: number; public videoQualityMode: VideoQualityMode | null; public createInvite(options?: InviteCreateOptions): Promise<Invite>; public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>; public setBitrate(bitrate: number, reason?: string): Promise<this>; public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this>; public setUserLimit(userLimit: number, reason?: string): Promise<this>; public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<this>; } export type EnumLike<Enum, Value> = Record<keyof Enum, Value>; export class BitField<Flags extends string, Type extends number | bigint = number> { public constructor(bits?: BitFieldResolvable<Flags, Type>); public bitfield: Type; public add(...bits: BitFieldResolvable<Flags, Type>[]): BitField<Flags, Type>; public any(bit: BitFieldResolvable<Flags, Type>): boolean; public equals(bit: BitFieldResolvable<Flags, Type>): boolean; public freeze(): Readonly<BitField<Flags, Type>>; public has(bit: BitFieldResolvable<Flags, Type>): boolean; public missing(bits: BitFieldResolvable<Flags, Type>, ...hasParams: readonly unknown[]): Flags[]; public remove(...bits: BitFieldResolvable<Flags, Type>[]): BitField<Flags, Type>; public serialize(...hasParams: readonly unknown[]): Record<Flags, boolean>; public toArray(...hasParams: readonly unknown[]): Flags[]; public toJSON(): Type extends number ? number : string; public valueOf(): Type; public [Symbol.iterator](): IterableIterator<Flags>; public static Flags: EnumLike<unknown, 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<true>, data: RawMessageButtonInteractionData); public componentType: ComponentType.Button; public get component(): CacheTypeReducer< Cached, ButtonComponent, APIButtonComponent, ButtonComponent | APIButtonComponent, ButtonComponent | APIButtonComponent >; public inGuild(): this is ButtonInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ButtonInteraction<'cached'>; public inRawGuild(): this is ButtonInteraction<'raw'>; } export type AnyComponent = | APIMessageComponent | APIModalComponent | APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>; export class Component<RawComponentData extends AnyComponent = AnyComponent> { public readonly data: Readonly<RawComponentData>; public get type(): RawComponentData['type']; public toJSON(): RawComponentData; public equals(other: this | RawComponentData): boolean; } export class ButtonComponent extends Component<APIButtonComponent> { private constructor(data: APIButtonComponent); public get style(): ButtonStyle; public get label(): string | null; public get emoji(): APIMessageComponentEmoji | null; public get disabled(): boolean; public get customId(): string | null; public get url(): string | null; } export type ComponentEmojiResolvable = APIMessageComponentEmoji | string; export class ButtonBuilder extends BuilderButtonComponent { public constructor(data?: Partial<ButtonComponentData> | Partial<APIButtonComponent>); public static from(other: JSONEncodable<APIButtonComponent> | APIButtonComponent): ButtonBuilder; public override setEmoji(emoji: ComponentEmojiResolvable): this; } export class StringSelectMenuBuilder extends BuilderStringSelectMenuComponent { public constructor(data?: Partial<StringSelectMenuComponentData | APIStringSelectComponent>); private static normalizeEmoji( selectMenuOption: JSONEncodable<APISelectMenuOption> | SelectMenuComponentOptionData, ): (APISelectMenuOption | StringSelectMenuOptionBuilder)[]; public override addOptions( ...options: RestOrArray<BuildersSelectMenuOption | SelectMenuComponentOptionData | APISelectMenuOption> ): this; public override setOptions( ...options: RestOrArray<BuildersSelectMenuOption | SelectMenuComponentOptionData | APISelectMenuOption> ): this; public static from( other: JSONEncodable<APIStringSelectComponent> | APIStringSelectComponent, ): StringSelectMenuBuilder; } export { /** @deprecated Use {@link StringSelectMenuBuilder} instead */ StringSelectMenuBuilder as SelectMenuBuilder, /** @deprecated Use {@link StringSelectMenuOptionBuilder} instead */ StringSelectMenuOptionBuilder as SelectMenuOptionBuilder, }; export class UserSelectMenuBuilder extends BuilderUserSelectMenuComponent { public constructor(data?: Partial<UserSelectMenuComponentData | APIUserSelectComponent>); public static from(other: JSONEncodable<APIUserSelectComponent> | APIUserSelectComponent): UserSelectMenuBuilder; } export class RoleSelectMenuBuilder extends BuilderRoleSelectMenuComponent { public constructor(data?: Partial<RoleSelectMenuComponentData | APIRoleSelectComponent>); public static from(other: JSONEncodable<APIRoleSelectComponent> | APIRoleSelectComponent): RoleSelectMenuBuilder; } export class MentionableSelectMenuBuilder extends BuilderMentionableSelectMenuComponent { public constructor(data?: Partial<MentionableSelectMenuComponentData | APIMentionableSelectComponent>); public static from( other: JSONEncodable<APIMentionableSelectComponent> | APIMentionableSelectComponent, ): MentionableSelectMenuBuilder; } export class ChannelSelectMenuBuilder extends BuilderChannelSelectMenuComponent { public constructor(data?: Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>); public static from( other: JSONEncodable<APIChannelSelectComponent> | APIChannelSelectComponent, ): ChannelSelectMenuBuilder; } export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption { public constructor(data?: SelectMenuComponentOptionData | APISelectMenuOption); public override setEmoji(emoji: ComponentEmojiResolvable): this; public static from(other: JSONEncodable<APISelectMenuOption> | APISelectMenuOption): StringSelectMenuOptionBuilder; } export class ModalBuilder extends BuildersModal { public constructor(data?: Partial<ModalComponentData> | Partial<APIModalInteractionResponseCallbackData>); public static from( other: JSONEncodable<APIModalInteractionResponseCallbackData> | APIModalInteractionResponseCallbackData, ): ModalBuilder; } export class TextInputBuilder extends BuilderTextInputComponent { public constructor(data?: Partial<TextInputComponentData | APITextInputComponent>); public static from(other: JSONEncodable<APITextInputComponent> | APITextInputComponent): TextInputBuilder; } export class TextInputComponent extends Component<APITextInputComponent> { public get customId(): string; public get value(): string; } export class BaseSelectMenuComponent<Data extends APISelectMenuComponent> extends Component<Data> { protected constructor(data: Data); public get placeholder(): string | null; public get maxValues(): number | null; public get minValues(): number | null; public get customId(): string; public get disabled(): boolean; } export class StringSelectMenuComponent extends BaseSelectMenuComponent<APIStringSelectComponent> { public get options(): APISelectMenuOption[]; } export { /** @deprecated Use {@link StringSelectMenuComponent} instead */ StringSelectMenuComponent as SelectMenuComponent, }; export class UserSelectMenuComponent extends BaseSelectMenuComponent<APIUserSelectComponent> {} export class RoleSelectMenuComponent extends BaseSelectMenuComponent<APIRoleSelectComponent> {} export class MentionableSelectMenuComponent extends BaseSelectMenuComponent<APIMentionableSelectComponent> {} export class ChannelSelectMenuComponent extends BaseSelectMenuComponent<APIChannelSelectComponent> { public getChannelTypes(): ChannelType[] | null; } export interface EmbedData { title?: string; type?: EmbedType; description?: string; url?: string; timestamp?: string | number | Date; color?: number; footer?: EmbedFooterData; image?: EmbedAssetData; thumbnail?: EmbedAssetData; provider?: APIEmbedProvider; author?: EmbedAuthorData; fields?: readonly APIEmbedField[]; video?: EmbedAssetData; } export interface IconData { iconURL?: string; proxyIconURL?: string; } export interface EmbedAuthorData extends Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'>, IconData {} export interface EmbedFooterData extends Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'>, IconData {} export interface EmbedAssetData extends Omit<APIEmbedImage, 'proxy_url'> { proxyURL?: string; } export class EmbedBuilder extends BuildersEmbed { public constructor(data?: EmbedData | APIEmbed); public override setColor(color: ColorResolvable | null): this; public static from(other: JSONEncodable<APIEmbed> | APIEmbed): EmbedBuilder; public get length(): number; } export class Embed { private constructor(data: APIEmbed); public readonly data: Readonly<APIEmbed>; public get fields(): APIEmbedField[]; public get footer(): EmbedFooterData | null; public get title(): string | null; public get description(): string | null; public get url(): string | null; public get color(): number | null; public get hexColor(): string | null; public get timestamp(): string | null; public get thumbnail(): EmbedAssetData | null; public get image(): EmbedAssetData | null; public get author(): EmbedAuthorData | null; public get provider(): APIEmbedProvider | null; public get video(): EmbedAssetData | null; public get length(): number; public equals(other: Embed | APIEmbed): boolean; public toJSON(): APIEmbed; } export interface MappedChannelCategoryTypes { [ChannelType.GuildAnnouncement]: NewsChannel; [ChannelType.GuildVoice]: VoiceChannel; [ChannelType.GuildText]: TextChannel; [ChannelType.GuildStageVoice]: StageChannel; [ChannelType.GuildForum]: ForumChannel; [ChannelType.GuildMedia]: MediaChannel; } export type CategoryChannelType = Exclude< ChannelType, | ChannelType.DM | ChannelType.GroupDM | ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread | ChannelType.GuildCategory | ChannelType.GuildDirectory >; export class CategoryChannel extends GuildChannel { public get children(): CategoryChannelChildManager; public type: ChannelType.GuildCategory; public get parent(): null; public parentId: null; } export type CategoryChannelResolvable = Snowflake | CategoryChannel; export type ChannelFlagsString = keyof typeof ChannelFlags; export type ChannelFlagsResolvable = BitFieldResolvable<ChannelFlagsString, number>; export class ChannelFlagsBitField extends BitField<ChannelFlagsString> { public static Flags: typeof ChannelFlags; public static resolve(bit?: BitFieldResolvable<ChannelFlagsString, ChannelFlags>): number; } export abstract class BaseChannel extends Base { public constructor(client: Client<true>, data?: RawChannelData, immediatePatch?: boolean); public get createdAt(): Date | null; public get createdTimestamp(): number | null; public id: Snowflake; public flags: Readonly<ChannelFlagsBitField> | null; public get partial(): false; public type: ChannelType; public get url(): string; public delete(): Promise<this>; public fetch(force?: boolean): Promise<this>; public isThread(): this is AnyThreadChannel; public isTextBased(): this is TextBasedChannel; public isDMBased(): this is PartialGroupDMChannel | DMChannel | PartialDMChannel; public isVoiceBased(): this is VoiceBasedChannel; public isThreadOnly(): this is ThreadOnlyChannel; public isSendable(): this is SendableChannels; public toString(): ChannelMention | UserMention; } export type If<Value extends boolean, TrueResult, FalseResult = null> = Value extends true ? TrueResult : Value extends false ? FalseResult : TrueResult | FalseResult; 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; private get _censoredToken(): string | null; // This a technique used to brand the ready state. Or else we'll get `never` errors on typeguard checks. private readonly _ready: Ready; // Override inherited static EventEmitter methods, with added type checks for Client events. public static once<Emitter extends EventEmitter, Event extends keyof ClientEvents>( eventEmitter: Emitter, eventName: Emitter extends Client ? Event : string | symbol, options?: { signal?: AbortSignal | undefined }, ): Promise<Emitter extends Client ? ClientEvents[Event] : any[]>; public static on<Emitter extends EventEmitter, Event extends keyof ClientEvents>( eventEmitter: Emitter, eventName: Emitter extends Client ? Event : string | symbol, options?: { signal?: AbortSignal | undefined }, ): AsyncIterableIterator<Emitter extends Client ? ClientEvents[Event] : any[]>; public application: If<Ready, ClientApplication>; public channels: ChannelManager; public get emojis(): BaseGuildEmojiManager; public guilds: GuildManager; public options: Omit<ClientOptions, 'intents'> & { intents: IntentsBitField }; public get readyAt(): If<Ready, Date>; public readyTimestamp: If<Ready, number>; public sweepers: Sweepers; public shard: ShardClientUtil | null; public token: If<Ready, string, string | null>; public get uptime(): If<Ready, number>; public user: If<Ready, ClientUser>; public users: UserManager; public voice: ClientVoiceManager; public ws: WebSocketManager; public destroy(): Promise<void>; public deleteWebhook(id: Snowflake, options?: WebhookDeleteOptions): 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 fetchStickerPacks(options: { packId: Snowflake }): Promise<StickerPack>; public fetchStickerPacks(options?: StickerPackFetchOptions): Promise<Collection<Snowflake, StickerPack>>; /** @deprecated Use {@link Client.fetchStickerPacks} instead. */ public fetchPremiumStickerPacks(): ReturnType<Client['fetchStickerPacks']>; public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>; public fetchGuildWidget(guild: GuildResolvable): Promise<Widget>; public generateInvite(options?: InviteGenerationOptions): string; public login(token?: string): Promise<string>; public isReady(): this is Client<true>; public toJSON(): unknown; public on<Event extends keyof ClientEvents>(event: Event, listener: (...args: ClientEvents[Event]) => void): this; public on<Event extends string | symbol>( event: Exclude<Event, keyof ClientEvents>, listener: (...args: any[]) => void, ): this; public once<Event extends keyof ClientEvents>(event: Event, listener: (...args: ClientEvents[Event]) => void): this; public once<Event extends string | symbol>( event: Exclude<Event, keyof ClientEvents>, listener: (...args: any[]) => void, ): this; public emit<Event extends keyof ClientEvents>(event: Event, ...args: ClientEvents[Event]): boolean; public emit<Event extends string | symbol>(event: Exclude<Event, keyof ClientEvents>, ...args: unknown[]): boolean; public off<Event extends keyof ClientEvents>(event: Event, listener: (...args: ClientEvents[Event]) => void): this; public off<Event extends string | symbol>( event: Exclude<Event, keyof ClientEvents>, listener: (...args: any[]) => void, ): this; public removeAllListeners<Event extends keyof ClientEvents>(event?: Event): this; public removeAllListeners<Event extends string | symbol>(event?: Exclude<Event, keyof ClientEvents>): this; } export interface StickerPackFetchOptions { packId?: Snowflake; } export class ClientApplication extends Application { private constructor(client: Client<true>, data: RawClientApplicationData); public botPublic: boolean | null; public botRequireCodeGrant: boolean | null; public bot: User | null; public commands: ApplicationCommandManager; public emojis: ApplicationEmojiManager; public entitlements: EntitlementManager; public subscriptions: SubscriptionManager; public guildId: Snowflake | null; public get guild(): Guild | null; public flags: Readonly<ApplicationFlagsBitField>; public approximateGuildCount: number | null; public approximateUserInstallCount: number | null; public tags: string[]; public installParams: ClientApplicationInstallParams | null; public integrationTypesConfig: IntegrationTypesConfiguration | null; public customInstallURL: string | null; public owner: User | Team | null; public get partial(): boolean; public interactionsEndpointURL: string | null; public eventWebhooksURL: string | null; public eventWebhooksStatus: ApplicationWebhookEventStatus | null; public eventWebhooksTypes: ApplicationWebhookEventType[] | null; public roleConnectionsVerificationURL: string | null; public edit(options: ClientApplicationEditOptions): Promise<ClientApplication>; public fetch(): Promise<ClientApplication>; public fetchRoleConnectionMetadataRecords(): Promise<ApplicationRoleConnectionMetadata[]>; public fetchSKUs(): Promise<Collection<Snowflake, SKU>>; public editRoleConnectionMetadataRecords( records: readonly ApplicationRoleConnectionMetadataEditOptions[], ): Promise<ApplicationRoleConnectionMetadata[]>; } export class ClientPresence extends Presence { private constructor(client: Client<true>, data: RawPresenceData); private _parse(data: PresenceData): RawPresenceData; public set(presence: PresenceData): ClientPresence; } export class ClientUser extends User { public mfaEnabled: boolean; public get presence(): ClientPresence; public verified: boolean; public edit(options: ClientUserEditOptions): Promise<this>; public setActivity(options?: ActivityOptions): ClientPresence; public setActivity(name: string, options?: Omit<ActivityOptions, 'name'>): ClientPresence; public setAFK(afk?: boolean, shardId?: number | readonly 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 | readonly number[]): ClientPresence; public setUsername(username: string): Promise<this>; } export class Options extends null { private constructor(); private static userAgentAppendix: string; public static get DefaultMakeCacheSettings(): CacheWithLimitsOptions; public static get 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, ReadonlyCollection } from '@discordjs/collection'; export interface CollectorEventTypes<Key, Value, Extras extends unknown[] = []> { collect: [Value, ...Extras]; ignore: [Value, ...Extras]; dispose: [Value, ...Extras]; end: [collected: ReadonlyCollection<Key, Value>, reason: string]; } export abstract class Collector<Key, Value, Extras extends unknown[] = []> extends EventEmitter { protected constructor(client: Client<true>, options?: CollectorOptions<[Value, ...Extras]>); private _timeout: NodeJS.Timeout | null; private _idletimeout: NodeJS.Timeout | null; private _endReason: string | null; public readonly client: Client; public collected: Collection<Key, Value>; public lastCollectedTimestamp: number | null; public get lastCollectedAt(): Date | null; public ended: boolean; public get endReason(): string | null; public filter: CollectorFilter<[Value, ...Extras]>; public get next(): Promise<Value>; public options: CollectorOptions<[Value, ...Extras]>; 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<[Value, ...Extras]>; public toJSON(): unknown; protected listener: (...args: any[]) => void; public abstract collect(...args: unknown[]): Awaitable<Key | null>; public abstract dispose(...args: unknown[]): Key | null; public on<EventKey extends keyof CollectorEventTypes<Key, Value, Extras>>( event: EventKey, listener: (...args: CollectorEventTypes<Key, Value, Extras>[EventKey]) => void, ): this; public once<EventKey extends keyof CollectorEventTypes<Key, Value, Extras>>( event: EventKey, listener: (...args: CollectorEventTypes<Key, Value, Extras>[EventKey]) => void, ): this; } export class ChatInputCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> { public commandType: ApplicationCommandType.ChatInput; public options: Omit<CommandInteractionOptionResolver<Cached>, 'getMessage' | 'getFocused'>; public inGuild(): this is ChatInputCommandInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ChatInputCommandInteraction<'cached'>; public inRawGuild(): this is ChatInputCommandInteraction<'raw'>; public toString(): string; } export class AutocompleteInteraction<Cached extends CacheType = CacheType> extends BaseInteraction<Cached> { public type: InteractionType.ApplicationCommandAutocomplete; public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null; public channelId: Snowflake; public commandId: Snowflake; public commandName: string; public commandType: ApplicationCommandType.ChatInput; public commandGuildId: Snowflake | null; public responded: boolean; public options: Omit< CommandInteractionOptionResolver<Cached>, 'getMessage' | 'getUser' | 'getAttachment' | 'getChannel' | 'getMember' | 'getMentionable' | 'getRole' >; public inGuild(): this is AutocompleteInteraction<'raw' | 'cached'>; public inCachedGuild(): this is AutocompleteInteraction<'cached'>; public inRawGuild(): this is AutocompleteInteraction<'raw'>; public respond(options: readonly ApplicationCommandOptionChoiceData[]): Promise<v