disjsx
Version:
A library for creating Discord messages in JSX
43 lines • 2.17 kB
TypeScript
import { type ReactElement } from "react";
import { type LegacyMessagePayload, type V2MessagePayload, type ModalPayload } from "./types";
export * from "./disjsxTypes";
export * from "./types";
export * from "./utils";
export * from "./processChildrenToString";
export * from "./nodes";
export * from "./validation";
/**
* Renders a DISJSX `<Message>` element and its children into a Discord message payload object.
* This is the main entry point for converting a DISJSX tree into a usable payload.
*
* It differentiates between V2 component-based messages and legacy messages (which can include
* content, embeds, and components). The `isV2` prop on the `<Message>` component
* dictates the output structure.
*
* For V2 messages, it primarily processes children into a `components` array.
* For legacy messages, it populates `content`, `embeds`, and `components` fields
* based on the DISJSX children (`<Content>`, `<Embed>`, `<ActionRow>`).
*
* @param messageElement The root `<Message>` React element or a component that renders to a Message element.
* @param options Optional configuration for validation and error handling.
* @returns A `LegacyMessagePayload` or `V2MessagePayload` object, or null if the input is invalid.
*/
export declare const renderDiscordMessage: (messageElement: ReactElement, options?: {
validate?: boolean;
throwOnValidationError?: boolean;
}) => LegacyMessagePayload | V2MessagePayload | null;
/**
* Renders a DISJSX `<Modal>` element and its children into a Discord modal payload object.
* This function is specifically for converting modal DISJSX trees into usable modal payloads.
*
* Modals can only contain Action Rows with Text Input components.
*
* @param modalElement The root `<Modal>` React element or a component that renders to a Modal element.
* @param options Optional configuration for validation and error handling.
* @returns A `ModalPayload` object, or null if the input is invalid.
*/
export declare const renderDiscordModal: (modalElement: ReactElement, options?: {
validate?: boolean;
throwOnValidationError?: boolean;
}) => ModalPayload | null;
//# sourceMappingURL=index.d.ts.map