import { type RestOrArray } from '../common'; import { type APIModalInteractionResponseCallbackData, type APITextInputComponent, type TextInputStyle } from '../types'; import { BaseComponentBuilder, type OptionValuesLength } from './Base'; import type { ModalBuilderComponents, ModalSubmitCallback } from './types'; /** * Represents a modal for user interactions. * @template T - The type of components allowed in the modal. * @example * const modal = new Modal(); * modal.setTitle("Sample Modal"); * modal.setCustomId("sample-modal"); * modal.addComponents( * new Label() * .setLabel("Enter text") * .setComponent( * new TextInput() * .setCustomId("sample-input") * .setStyle(TextInputStyle.Paragraph) * ) * ); * modal.run((interaction) => { * // Handle modal submission * }); * const json = modal.toJSON(); */ export declare class Modal { data: Partial; components: ModalBuilderComponents[]; /** * Creates a new Modal instance. * @param data - Optional data for the modal. */ constructor(data?: Partial); /** * Adds components to the modal. * @param components - Components to be added to the modal. * @returns The current Modal instance. */ addComponents(...components: RestOrArray): this; /** * Set the components to the modal. * @param component - The components to set into the modal. * @returns The current Modal instance. */ setComponents(component: ModalBuilderComponents[]): this; /** * Sets the title of the modal. * @param title - The title of the modal. * @returns The current Modal instance. */ setTitle(title: string): this; /** * Sets the custom ID of the modal. * @param id - The custom ID for the modal. * @returns The current Modal instance. */ setCustomId(id: string): this; /** * Sets the callback function to be executed when the modal is submitted. * @param func - The callback function. * @returns The current Modal instance. */ run(func: ModalSubmitCallback): this; /** * Converts the modal to JSON format. * @returns The modal data in JSON format. */ toJSON(): APIModalInteractionResponseCallbackData; } /** * Represents a text input component builder. * @example * const textInput = new TextInput() * .setCustomId("feedback") * .setStyle(TextInputStyle.Paragraph) * .setPlaceholder("Type here"); * const label = new Label() * .setLabel("Feedback") * .setComponent(textInput); * const json = label.toJSON(); */ export declare class TextInput extends BaseComponentBuilder { /** * Creates a new TextInput instance. * @param data - Optional data for the text input. */ constructor(data?: Partial); /** * Sets the style of the text input. * @param style - The style of the text input. * @returns The current TextInput instance. */ setStyle(style: TextInputStyle): this; /** * Sets the placeholder of the text input. * @param placeholder - The placeholder text. * @returns The current TextInput instance. */ setPlaceholder(placeholder: string): this; /** * Sets the length constraints for the text input. * @param options - The length constraints. * @returns The current TextInput instance. */ setLength({ max, min }: Partial): this; /** * Sets the custom ID of the text input. * @param id - The custom ID for the text input. * @returns The current TextInput instance. */ setCustomId(id: string): this; /** * Sets the initial value of the text input. * @param value - The initial value. * @returns The current TextInput instance. */ setValue(value: string): this; /** * Sets whether the text input is required. * @param required - Indicates whether the text input is required. * @returns The current TextInput instance. */ setRequired(required?: boolean): this; }