import { DiscordApiClient } from "@discord-interactions/api"; import type { APIInteractionResponse, Snowflake } from "discord-api-types/v10"; import type { FormData } from "formdata-node"; import { ContextMap, InteractionHooks } from "./index.js"; import { CommandManager } from "./managers/CommandManager.js"; import { ComponentManager } from "./managers/ComponentManager.js"; /** Cache used to store component states. Redis is recommended. */ export interface GenericCache { /** Default Time To Live for cache entries, defaults to 900. */ ttl?: number; get: (key: string) => Promise; set: (key: string, ttl: number, value: string) => Promise; } export interface DiscordApplicationOptions { /** Application Client ID */ clientId: Snowflake; /** Application Public Key */ publicKey: string; /** Application Bot Token */ token: string; /** Hooks to perform additional processing on certain interactions before passing to their handlers. Upon returning true, all further execution is halted. */ hooks?: Partial; /** Component State Cache */ cache?: GenericCache; /** What mode to use for syncing the global command manager. */ syncMode?: SyncMode; /** Whether to preserve the raw interaction object in contexts under ctx.raw - Default: false */ preserveRaw?: boolean; /** Timeout after which InteractionHandlerTimedOut is thrown - Default: 2500ms */ timeout?: number; } export declare type ResponseCallback = (response: T) => void; export declare enum SyncMode { Disabled = "off", Enabled = "on", Strict = "strict" } /** * Main class for managing a Discord Application's commands and handling interactions. */ export declare class DiscordApplication { private token; publicKey: string; clientId: Snowflake; cache?: GenericCache; commands: CommandManager; guildCommands: Map; components: ComponentManager; preserveRaw: boolean; timeout: number; hooks: InteractionHooks; rest: DiscordApiClient; constructor(options: DiscordApplicationOptions); /** * Verify an incoming interaction's signature. * @param timestamp Interaction Request's "X-Signature-Timestamp" Header * @param signature Interaction Request's "X-Signature-Ed25519" Header * @param body Raw Interaction Request Body - If you parse this as JSON beforehand, verification will fail for certain interactions. * @returns Whether or not the request signature is valid. */ verifyInteractionSignature(signature: string, timestamp: string, body: string): Promise; createGuildCommandManager(guildId: Snowflake, syncMode?: SyncMode): CommandManager; setAPIClient(client: DiscordApiClient): void; /** * Handle an incoming interaction request * @param body Raw interaction body * @param signature Request's "X-Signature-Ed25519" header or false to skip signature verification * @param timestamp Request's "X-Signature-Timestamp" header * @returns Array containing the interaction response, and a callback to be called after you have sent the response */ handleInteraction(body: string, signature: string | false, timestamp?: string): Promise<[Promise, Promise]>; private _handleInteraction; addHook(hook: T, handler: (ctx: ContextMap[T]) => Promise): void; }