import { type APIComponentInMessageActionRow, type APIComponentInModalActionRow, type APIMessageTopLevelComponent, type APIModalComponent, type JSONEncodable } from "discord.js"; import { type APIComponent } from "../@types"; /** * The sequence of mapping components from priority to sub components * * How it is received: * `action row` -> `sub components` * * How it is mapped: * `sub components` -> `action row` * * @param callback - You can `return` the `modified component` or `delete it with null`. * @returns A new modified array (the original structure will not be modified) * * @example * ```ts * mapComponents(components, (component, index) => { * // Skip non matched components * if (component.type !== ComponentType.Button) return component; * // Delete a component * if (component.style !== ButtonStyle.Link) return null; * // filter components * if (component.label !== "example") return component * // Modify component * component.label = "modified" * // Return modified component * return component; * }); */ export declare function mapComponents(components: (T | JSONEncodable)[], callback: (component: U, componentIndex: number) => U | JSONEncodable | null): JSONEncodable[]; export declare function mapComponents(components: (T | JSONEncodable)[], callback: (component: U, componentIndex: number) => U | JSONEncodable | null): JSONEncodable[]; export declare function mapComponents(components: (APIComponent | JSONEncodable)[], callback: (component: U, componentIndex: number) => U | JSONEncodable | null): JSONEncodable[]; export declare function mapComponents(components: (APIComponent | JSONEncodable)[], callback: (component: APIComponent, componentIndex: number) => APIComponent | JSONEncodable | null): JSONEncodable[];