/** * Builder class for managing Telegram bot commands * * @module builders/BotCommandsBuilder * @example * ```typescript * const commands = new BotCommandsBuilder() * .addCommand('start', 'Start the bot') * .addCommand('help', 'Show help information') * .addCommand('settings', 'Configure bot settings') * .build(); * * await api.setMyCommands(commands); * ``` */ import { BotCommand } from '../api/types/index.js'; /** * Builder for managing bot commands with fluent API * Implements structure for operations with Telegram bot's commands */ export declare class BotCommandsBuilder { private commands; /** * Creates a new BotCommandsBuilder instance * * @param commands - Initial array of commands (optional) */ constructor(commands?: BotCommand[]); /** * Add a command to the bot's commands array * The command will not be added if it already exists * * @param command - Command name (without leading slash) * @param description - Command description * @returns This builder instance for chaining, or false if command already exists * @throws {TelegramValidationError} If command parameters are invalid */ addCommand(command: string, description: string): this; /** * Check if a command exists in the commands array * * @param command - Command name to check * @returns True if the command exists, false otherwise */ commandExists(command: string): boolean; /** * Delete a command from the commands array * This is the fixed version - the original had a bug in the filter implementation * * @param command - Command name to delete * @returns This builder instance for chaining */ deleteCommand(command: string): this; /** * Get a command by its name * * @param command - Command name to find * @returns The BotCommand object if found, undefined otherwise */ getCommand(command: string): BotCommand | undefined; /** * Update the description of an existing command * * @param command - Command name to update * @param description - New description * @returns This builder instance for chaining * @throws {TelegramValidationError} If command does not exist */ updateCommand(command: string, description: string): this; /** * Clear all commands * * @returns This builder instance for chaining */ clear(): this; /** * Get the number of commands * * @returns The number of commands in the array */ getCount(): number; /** * Check if the commands array is empty * * @returns True if there are no commands, false otherwise */ isEmpty(): boolean; /** * Build and return the final array of BotCommand objects * * @returns Array of BotCommand objects */ build(): BotCommand[]; /** * Get the raw commands array (useful for debugging or advanced manipulation) * Note: Direct modification of this array is not recommended * * @returns The internal commands array */ getRawCommands(): BotCommand[]; /** * Create a BotCommandsBuilder from an existing array of commands * * @param commands - Array of BotCommand objects * @returns A new BotCommandsBuilder instance */ static fromArray(commands: BotCommand[]): BotCommandsBuilder; /** * Merge commands from another builder or array * Existing commands will not be overwritten * * @param source - Another BotCommandsBuilder instance or array of commands * @returns This builder instance for chaining */ merge(source: BotCommandsBuilder | BotCommand[]): this; /** * Sort commands alphabetically by command name * * @returns This builder instance for chaining */ sort(): this; }