import { ApiMessageAttachment, ApiMessageMention, ChannelMessageContent, IInteractiveMessageProps } from 'mezon-sdk/dist/cjs/interfaces/client'; import type { ChannelMessage } from 'mezon-sdk'; import type { Message } from 'mezon-sdk/dist/cjs/mezon-client/structures/Message'; import type { NezonCommandContext } from '../interfaces/command-context.interface'; import { ButtonBuilder, ButtonComponent, ButtonClickHandler } from './button-builder'; import { EmbedBuilder } from './embed-builder'; type MentionInput = string | { user_id?: string; userId?: string; username?: string; display_name?: string; role_id?: string; roleId?: string; role_name?: string; roleName?: string; type?: 'user' | 'role'; }; type MentionPlaceholderUser = { kind: 'user'; userId: string; label?: string; }; type MentionPlaceholderRole = { kind: 'role'; roleId?: string; roleName?: string; }; type MentionPlaceholderValue = MentionPlaceholderUser | MentionPlaceholderRole; export interface NormalizedSmartMessage { content: ChannelMessageContent; attachments?: ApiMessageAttachment[]; mentions?: ApiMessageMention[]; mentionPlaceholders?: Record; } export declare function cloneMentionPlaceholders(placeholders?: Record): Record | undefined; export type SmartMessageLike = SmartMessage | NormalizedSmartMessage | ChannelMessageContent | string; /** * Global registry for button onClick handlers. * This is a singleton that can be accessed without DI. */ declare class ButtonClickRegistry { private handlers; register(customId: string, handler: ButtonClickHandler): void; getHandler(customId: string): ButtonClickHandler | undefined; hasHandler(customId: string): boolean; unregister(customId: string): void; clear(): void; } /** * Gets the global button click registry. * Used internally by component service to handle onClick handlers. * * @internal */ export declare function getButtonClickRegistry(): ButtonClickRegistry; /** * Fluent builder for channel message payloads bundled with optional attachments, components, and embeds. */ export declare class SmartMessage { private readonly content; private components; private attachments; private embeds; private mentionPlaceholders; private constructor(); static text(content: string): SmartMessage; static build(): SmartMessage; static system(content: string): SmartMessage; static voice(url: string, options?: { transcript?: string; filename?: string; }): SmartMessage; static image(url: string, options?: { alt?: string; filename?: string; width?: number; height?: number; }): SmartMessage; static raw(content: ChannelMessageContent, attachments?: ApiMessageAttachment[]): SmartMessage; /** * Adds a button component to the message. * Buttons are automatically grouped into action rows (max 5 buttons per row). * If the button has an onClick handler, it will be automatically registered. * * @param button - A ButtonBuilder instance or a built ButtonComponent * @returns This SmartMessage instance for method chaining * * @example * ```ts * const msg = SmartMessage.text('Click the button!') * .addButton( * new ButtonBuilder() * .setCustomId('click/12345') * .setLabel('Click Me') * .setStyle(ButtonStyle.Primary) * ); * ``` * * @example With onClick handler * ```ts * const msg = SmartMessage.text('Click the button!') * .addButton( * new ButtonBuilder() * .setLabel('Click Me') * .setStyle(ButtonStyle.Primary) * .onClick(async (context) => { * // Handler will be automatically registered * }) * ); * ``` */ addButton(button: ButtonBuilder | ButtonComponent): this; /** * Adds an image attachment to the message. * * @param url - The URL of the image * @param options - Optional image configuration (filename, dimensions) * @returns This SmartMessage instance for method chaining * * @example * ```ts * const msg = SmartMessage.text('Check out this image!') * .addImage('https://example.com/image.png', { * filename: 'example.png', * width: 800, * height: 600, * }); * ``` */ addImage(url: string, options?: { filename?: string; width?: number; height?: number; }): this; /** * Adds a file attachment to the message. * * @param url - The URL of the file * @param filename - The filename of the file * @param filetype - The MIME type of the file (e.g., 'application/x-zip-compressed', 'application/pdf') * @param options - Optional file configuration (size) * @returns This SmartMessage instance for method chaining * * @example * ```ts * const msg = SmartMessage.text('Here is a file!') * .addFile( * 'https://example.com/file.zip', * 'file.zip', * 'application/x-zip-compressed', * { size: 3215230 } * ); * ``` */ addFile(url: string, filename: string, filetype: string, options?: { size?: number; }): this; addGIF(url: string, options?: { filename?: string; width?: number; height?: number; size?: number; }): this; /** * Adds an embed to the message. * * @param embed - An EmbedBuilder instance or a built IInteractiveMessageProps object * @returns This SmartMessage instance for method chaining * * @example * ```ts * const msg = SmartMessage.text('Check out this embed!') * .addEmbed( * new EmbedBuilder() * .setColor('#f0a8da') * .setTitle('Title') * .setDescription('Description') * .addField('Field Name', 'Field Value', true) * .setThumbnail('https://example.com/thumb.png') * .setImage('https://example.com/image.png') * .setFooter('Footer text') * ); * ``` */ addEmbed(embed: EmbedBuilder | IInteractiveMessageProps): this; addMention(key: string, value: MentionInput): this; addMention(mentions: Record): this; toJSON(): NormalizedSmartMessage; toContent(): ChannelMessageContent; toAttachments(): ApiMessageAttachment[] | undefined; } interface ManagedMessageHelpers { normalize: (input: SmartMessageLike) => NormalizedSmartMessage; } export declare class DMHelper { private readonly client; private readonly helpers; constructor(client: import('mezon-sdk').MezonClient, helpers: ManagedMessageHelpers); send(userId: string, message: SmartMessageLike): Promise; private preparePayload; private fetchUsername; private applyMentionPlaceholders; } export declare class ChannelHelper { private readonly context; private readonly helpers; private readonly targetChannelId?; constructor(context: NezonCommandContext, helpers: ManagedMessageHelpers, targetChannelId?: string); send(message: SmartMessageLike): Promise; find(channelId: string): ChannelHelper; private resolveChannel; private preparePayload; private applyMentionPlaceholders; } /** * Wrapper around the current message entity providing convenience helpers * for replying or updating messages using {@link SmartMessage}. */ export declare class ManagedMessage { private readonly context; private readonly helpers; constructor(context: NezonCommandContext, helpers: ManagedMessageHelpers); get raw(): ChannelMessage; get id(): string | undefined; get channelId(): string | undefined; get senderId(): string | undefined; get isBotMessage(): boolean; reply(message: SmartMessageLike): Promise; update(message: SmartMessageLike): Promise; delete(): Promise; react(emoji: string, emojiId?: string, actionDelete?: boolean): Promise; addReaction(emoji: string, emojiId?: string): Promise; removeReaction(emoji: string, emojiId?: string): Promise; fetch(): Promise; sendDM(message: SmartMessageLike): Promise; private preparePayload; private applyMentionPlaceholders; } export {};