import { Adapter } from '@msgly/core'; interface DiscordConfig { /** Application ID from the Discord Developer Portal → General Information. */ applicationId: string; /** Bot token (Bot → Reset Token). Used to authenticate REST API calls. */ botToken: string; /** * Public Key for Ed25519 signature verification of incoming interactions. * Find it on the same General Information page. Hex string. */ publicKey: string; /** Override for tests. Defaults to https://discord.com/api. */ apiBase?: string; /** Discord REST API version. Defaults to v10. */ apiVersion?: string; } interface DiscordAdapter extends Adapter { readonly channel: 'discord'; } /** * Discord markdown formatting helpers. Discord always renders markdown — no * `format` hint is needed on TextContent. * * @example * content: { type: 'text', text: `${fmt.bold('Hello')} ${fmt.code('world')}` } */ declare const fmt: { bold: (t: string) => string; italic: (t: string) => string; underline: (t: string) => string; strikethrough: (t: string) => string; spoiler: (t: string) => string; code: (t: string) => string; codeBlock: (t: string, lang?: string) => string; link: (t: string, url: string) => string; }; /** * Discord adapter — receives slash commands and message-component (button) * clicks via HTTP Interactions, sends replies via the Bot REST API. * * Discord's webhook is unique in two ways: * * 1. **Ed25519 signature verification.** Every interaction includes * `X-Signature-Ed25519` and `X-Signature-Timestamp` headers. The signature * is computed over `timestamp + rawBody` using the application's public * key. The hub's webhook handler delegates to `verifySignature` before * dispatch. * * 2. **Required immediate acknowledgement.** The webhook MUST respond within * 3 seconds. Type 1 (PING) is the URL-verify challenge during dashboard * setup — reply with `{type: 1}`. Type 2/3 (commands/components) are * acknowledged deferred (`{type: 5}` or `{type: 6}`); the real reply is * sent later via a followup. The hub calls `getInteractionAck` to obtain * this body and sends it before invoking `handleWebhook`. * * **Reply path.** Inbound messages carry `metadata.interactionToken`. When * you call `hub.send` with that metadata, the adapter PATCHes the original * deferred response, which replaces Discord's "thinking..." placeholder with * the actual reply. Without `interactionToken`, the adapter falls back to * posting directly to the channel using the Bot token. * * **Runtime requirement.** Ed25519 verification uses WebCrypto, which is * available natively in Node 20.13+, Bun, Deno, and modern browser/Edge * runtimes. On Node ≤ 20.12 the verification step will throw. */ declare function createDiscordAdapter(config: DiscordConfig): DiscordAdapter; export { type DiscordAdapter, type DiscordConfig, createDiscordAdapter, fmt };