import { ButtonComponent, EButtonMessageStyle } from 'mezon-sdk/dist/cjs/interfaces/client'; import type { ButtonClickContext } from '../interfaces/button-click-context.interface'; export type { ButtonComponent }; export type ButtonClickHandler = (context: ButtonClickContext) => Promise | void; /** * Builder for creating button components compatible with Mezon SDK. * Follows a fluent API pattern similar to Discord.js builders. * * @example * ```ts * const button = new ButtonBuilder() * .setCustomId('click/12345') * .setLabel('Click Me') * .setStyle(ButtonStyle.Primary) * .build(); * ``` */ export declare class ButtonBuilder { private id?; private label?; private style?; private disabled?; private url?; private onClickHandler?; /** * Sets the custom ID for the button. This ID will be used to identify * the button when it's clicked and can be matched via @Component decorator. * * @param customId - The custom identifier for the button * @returns This builder instance for method chaining * @throws Error if onClick handler is already set */ setCustomId(customId: string): this; /** * Sets an inline click handler for the button. This will automatically * generate a unique custom ID and register the handler. * Cannot be used together with setCustomId(). * * The handler receives a context object with pre-resolved entities: * - `message`: ManagedMessage instance with reply/update/delete methods * - `channel`: TextChannel instance (or undefined) * - `user`: User instance (or undefined) * - `clan`: Clan instance (or undefined) * - `client`: MezonClient instance * - `formData`: Parsed form inputs (if the button was submitted with embed form fields) * * @param handler - The handler function to execute when the button is clicked * @returns This builder instance for method chaining * @throws Error if customId is already set * * @example * ```ts * const button = new ButtonBuilder() * .setLabel('Click Me') * .setStyle(ButtonStyle.Primary) * .onClick(async (context) => { * await context.message.reply(SmartMessage.text('Button clicked!')); * const channelName = context.channel?.name ?? 'unknown'; * const userName = context.user?.username ?? 'unknown'; * const input = context.formData?.['feedback'] ?? 'no input'; * }); * ``` */ onClick(handler: ButtonClickHandler): this; /** * Gets the onClick handler if set. * * @internal */ getOnClickHandler(): ButtonClickHandler | undefined; /** * Sets the label text displayed on the button. * * @param label - The button label text * @returns This builder instance for method chaining */ setLabel(label: string): this; /** * Sets the visual style of the button. * * @param style - The button style (Primary, Secondary, Success, Danger, Link) * @returns This builder instance for method chaining */ setStyle(style: EButtonMessageStyle | ButtonStyle): this; /** * Sets whether the button is disabled. * * @param disabled - Whether the button should be disabled * @returns This builder instance for method chaining */ setDisabled(disabled: boolean): this; /** * Sets the URL for link-style buttons. * * @param url - The URL to navigate to when clicked * @returns This builder instance for method chaining */ setURL(url: string): this; /** * Generates a unique custom ID for onClick handlers. * Uses crypto.randomUUID() for guaranteed uniqueness across all users and instances. * * @internal */ private generateOnClickId; /** * Builds the button component according to Mezon SDK structure. * If onClick handler is set, automatically generates a unique custom ID. * * @returns A ButtonComponent ready to be added to message components * @throws Error if required fields (label) are missing or if neither customId nor onClick is set */ build(): ButtonComponent; } /** * Convenience enum for button styles matching EButtonMessageStyle. * Provides a cleaner API than using EButtonMessageStyle directly. */ export declare enum ButtonStyle { Primary = 1, Secondary = 2, Success = 3, Danger = 4, Link = 5 }