/** * Message formatting utilities for Discord * * Provides utilities for: * - Managing typing indicators during message processing * - Sending messages with automatic splitting * - Discord-specific markdown escaping * * Message splitting utilities are provided by @herdctl/chat. */ import type { DMChannel, NewsChannel, TextChannel, ThreadChannel } from "discord.js"; /** * Discord's maximum message length */ export declare const DISCORD_MAX_MESSAGE_LENGTH = 2000; /** * Supported text-based channel types that can receive messages */ export type SendableChannel = TextChannel | DMChannel | NewsChannel | ThreadChannel; /** * Options for sending split messages * * All MessageSplitOptions fields are optional here since we default maxLength * to DISCORD_MAX_MESSAGE_LENGTH when not provided. */ export interface SendSplitOptions { /** * Maximum length for each message chunk (defaults to DISCORD_MAX_MESSAGE_LENGTH) */ maxLength?: number; /** * Whether to try to split at natural boundaries like sentences (default: true) */ preserveBoundaries?: boolean; /** * Characters to use as split points, in order of preference */ splitPoints?: string[]; /** * Delay between messages in milliseconds (default: 500) */ delayMs?: number; } /** * Controller for managing a typing indicator loop */ export interface TypingController { /** * Stop the typing indicator */ stop(): void; /** * Whether the typing indicator is currently active */ readonly isActive: boolean; } /** * Start a typing indicator that refreshes automatically * * Discord typing indicators expire after ~10 seconds, so this function * sets up an interval to keep refreshing the typing status until stopped. * * @param channel - Channel to show typing indicator in * @param refreshInterval - How often to refresh (default: 5000ms) * @returns Controller to stop the typing indicator * * @example * ```typescript * const typing = startTypingIndicator(channel); * try { * const response = await processMessage(prompt); * await channel.send(response); * } finally { * typing.stop(); * } * ``` */ export declare function startTypingIndicator(channel: SendableChannel, refreshInterval?: number): TypingController; /** * Send a message, automatically splitting if needed * * @param channel - Channel to send the message to * @param content - Message content to send * @param options - Send options including split and delay settings * @returns Array of message IDs for sent messages * * @example * ```typescript * const messageIds = await sendSplitMessage(channel, longResponse, { * delayMs: 500, * preserveBoundaries: true, * }); * console.log(`Sent ${messageIds.length} messages`); * ``` */ export declare function sendSplitMessage(channel: SendableChannel, content: string, options?: SendSplitOptions): Promise; /** * Send a message with typing indicator * * Shows a typing indicator, processes the content, then sends the response. * Automatically splits long messages. * * @param channel - Channel to send the message to * @param contentProvider - Async function that generates the message content * @param options - Send options * @returns Array of message IDs for sent messages * * @example * ```typescript * const messageIds = await sendWithTyping(channel, async () => { * return await generateResponse(prompt); * }); * ``` */ export declare function sendWithTyping(channel: SendableChannel, contentProvider: () => Promise, options?: SendSplitOptions): Promise; /** * Escape Discord markdown characters in text * * @param text - Text to escape * @returns Text with markdown characters escaped */ export declare function escapeMarkdown(text: string): string; //# sourceMappingURL=formatting.d.ts.map