import { type APIApplicationCommand, type APIInteraction } from "discord-api-types/v10"; import type { BaseCommand } from "../abstracts/BaseCommand.js"; import type { AnyListener } from "../abstracts/BaseListener.js"; import type { BaseMessageInteractiveComponent } from "../abstracts/BaseMessageInteractiveComponent.js"; import type { Context, Plugin, Route } from "../abstracts/Plugin.js"; import { CommandHandler } from "../internals/CommandHandler.js"; import { ComponentHandler } from "../internals/ComponentHandler.js"; import { EmojiHandler } from "../internals/EmojiHandler.js"; import { EventHandler } from "../internals/EventHandler.js"; import type { EventQueueOptions } from "../internals/EventQueue.js"; import { ModalHandler } from "../internals/ModalHandler.js"; import { TemporaryListenerManager } from "../internals/TemporaryListenerManager.js"; import { Guild } from "../structures/Guild.js"; import { GuildMember } from "../structures/GuildMember.js"; import { Message } from "../structures/Message.js"; import { Role } from "../structures/Role.js"; import { User } from "../structures/User.js"; import { Webhook, type WebhookInput } from "../structures/Webhook.js"; import type { CommandMiddleware } from "../types/commandMiddleware.js"; import type { Modal } from "./Modal.js"; import { RequestClient, type RequestClientOptions, type RuntimeProfile } from "./RequestClient.js"; /** * The options used for initializing the client */ export interface ClientOptions { /** * The base URL of the app */ baseUrl: string; /** * The client ID of the app */ clientId: string; /** * The deploy secret of the app, used for protecting the deploy route */ deploySecret?: string; /** * The public key of the app, used for interaction verification * Can be a single key or an array of keys */ publicKey: string | string[]; /** * The token of the bot */ token: string; /** * Runtime profile for Carbon core scheduling defaults. * * @default "serverless" */ runtimeProfile?: RuntimeProfile; /** * The options used to initialize the request client, if you want to customize it. */ requestOptions?: RequestClientOptions; /** * Whether the commands should be deployed to Discord automatically. * @default false */ autoDeploy?: boolean; /** * The strategy to use when deploying global commands. * Guild and dev-guild deployments always use Discord's bulk overwrite route. * * @default "overwrite" */ commandDeploymentMode?: "overwrite" | "reconcile"; /** * Whether the deploy route should be disabled. * @default false */ disableDeployRoute?: boolean; /** * Whether the interactions route should be disabled * @default false */ disableInteractionsRoute?: boolean; /** * Whether the events route should be disabled * @default false */ disableEventsRoute?: boolean; /** * A list of guild IDs to deploy all commands to during development (guild command deployment is instant and rate-limited higher). * If set, all commands will be deployed to these guilds instead of globally. */ devGuilds?: string[]; /** * Configuration for the event queue worker pool */ eventQueue?: EventQueueOptions; /** * Middleware hooks that run around every command execution. * * These run before per-command middlewares. */ commandMiddlewares?: CommandMiddleware[]; } /** * The main client used to interact with Discord */ export declare class Client { /** * The routes that the client will handle */ routes: Route[]; /** * The plugins that the client has registered */ plugins: { id: string; plugin: Plugin; }[]; /** * The options used to initialize the client */ options: ClientOptions; /** * The commands that the client has registered */ commands: BaseCommand[]; /** * Registered global middleware hooks for command execution. */ commandMiddlewares: CommandMiddleware[]; /** * The event listeners that the client has registered */ listeners: AnyListener[]; /** * The rest client used to interact with the Discord API */ rest: RequestClient; /** * The handler for the component interactions sent from Discord * @internal */ componentHandler: ComponentHandler; /** * The handler for the modal interactions sent from Discord * @internal */ commandHandler: CommandHandler; /** * The handler for the modal interactions sent from Discord * @internal */ modalHandler: ModalHandler; /** * The handler for events sent from Discord * @internal */ eventHandler: EventHandler; /** * The manager for temporary event listeners with automatic cleanup */ temporaryListeners: TemporaryListenerManager; /** * The handler for application emojis for this application */ emoji: EmojiHandler; private cachedGlobalCommands; /** * The ID of the shard this client is running on, if sharding is enabled */ shardId?: number; /** * The total number of shards, if sharding is enabled */ totalShards?: number; /** * Creates a new client * @param options The options used to initialize the client * @param handlers The handlers that the client has registered * @param plugins The plugins that the client should use */ constructor(options: ClientOptions, handlers: { commands?: BaseCommand[]; listeners?: AnyListener[]; components?: BaseMessageInteractiveComponent[]; modals?: Modal[]; }, plugins?: Plugin[]); getPlugin(id: string): T | undefined; getRuntimeMetrics(): { request: { globalRateLimitUntil: number; activeBuckets: number; laneCounts: { critical: number; standard: number; background: number; }; laneDropped: { critical: number; standard: number; background: number; }; oldestByLane: { critical: number; standard: number; background: number; }; queueSize: number; activeWorkers: number; maxConcurrentWorkers: number; }; events: { queueSize: number; queueSizeByLane: { critical: number; standard: number; background: number; }; processingByLane: { critical: number; standard: number; background: number; }; processed: number; dropped: number; droppedStale: number; timeouts: number; zombieExecutions: number; oldestAgeMsByLane: { critical: number; standard: number; background: number; }; laneConfig: Record<"critical" | "standard" | "background", Required>; }; forwarder: unknown; }; private appendRoutes; /** * Handle a request to deploy the commands to Discord * @returns A response */ handleDeployRequest(req?: Request): Promise; deployCommands(options?: { mode?: "overwrite" | "reconcile"; }): Promise<{ mode: "overwrite" | "reconcile"; usedDevGuilds: boolean; }>; reconcileCommands(): Promise<{ mode: "overwrite" | "reconcile"; usedDevGuilds: boolean; }>; /** * Handle an interaction request from Discord * @param req The request to handle * @returns A response */ handleEventsRequest(req: Request): Promise; /** * Handle an interaction request from Discord * @param req The request to handle * @param ctx The context for the request * @returns A response */ handleInteractionsRequest(req: Request, ctx: Context): Promise; /** * Handle an interaction request from Discord * @param interaction The interaction to handle * @param ctx The context for the request * @returns A response */ handleInteraction(interaction: APIInteraction, ctx: Context): Promise; /** * Validate a request from Discord * @param req The request to validate */ protected validateDiscordRequest(req: Request): Promise; /** * Register an event listener with the client. * This method provides type-safe listener registration without requiring * manual type casting at the call site. * @param listener The listener to register */ registerListener(listener: T): void; /** * Fetch a user from the Discord API * @param id The ID of the user to fetch * @returns The user data */ fetchUser(id: string): Promise>; /** * Fetch a guild from the Discord API * @param id The ID of the guild to fetch * @returns The guild data */ fetchGuild(id: string): Promise>; /** * Fetch a channel from the Discord API * @param id The ID of the channel to fetch * @returns The channel data */ fetchChannel(id: string): Promise | import("../index.js").GuildTextChannel | import("../index.js").DmChannel | import("../index.js").GuildVoiceChannel | import("../index.js").GroupDmChannel | import("../index.js").GuildAnnouncementChannel | import("../index.js").GuildThreadChannel | import("../index.js").GuildThreadChannel | import("../index.js").GuildThreadChannel | import("../index.js").GuildStageChannel | import("../index.js").GuildForumChannel | import("../index.js").GuildMediaChannel>; /** * Fetch a role from the Discord API * @param guildId The ID of the guild the role is in * @param id The ID of the role to fetch * @returns The role data */ fetchRole(guildId: string, id: string): Promise>; /** * Fetch a member from the Discord API * @param guildId The ID of the guild the member is in * @param id The ID of the member to fetch * @returns The member data */ fetchMember(guildId: string, id: string): Promise>; /** * Fetch a message from the Discord API * @param channelId The ID of the channel the message is in * @param messageId The ID of the message to fetch * @returns The message data */ fetchMessage(channelId: string, messageId: string): Promise>; /** * Fetch a webhook from the Discord API * @param input The webhook data, ID and token, or webhook URL * @returns The webhook data */ fetchWebhook(input: WebhookInput): Promise>; getDiscordCommands(force?: boolean): Promise; private updateCommandIdsFromDeployment; private reconcileGlobalCommands; } /** * @hidden */ export interface ExecutionContext { waitUntil(promise: Promise): void; } //# sourceMappingURL=Client.d.ts.map