import { type APIChannelSelectComponent, type APIMentionableSelectComponent, type APIMessageComponentEmoji, type APIRoleSelectComponent, type APISelectMenuComponent, type APISelectMenuDefaultValue, type APISelectMenuOption, type APIStringSelectComponent, type APIUserSelectComponent, type ChannelType, ComponentType, SelectMenuDefaultValueType, } from '../types'; import type { EmojiResolvable, RestOrArray, ToClass } from '../common'; import type { ChannelSelectMenuInteraction, ComponentInteraction, MentionableSelectMenuInteraction, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserSelectMenuInteraction, } from '../structures'; import { resolvePartialEmoji } from '../common/it/utils'; import { BaseComponentBuilder, type OptionValuesLength } from './Base'; export type BuilderSelectMenus = | RoleSelectMenu | UserSelectMenu | MentionableSelectMenu | ChannelSelectMenu | StringSelectMenu; /** * Maps default values for Select Menus. * @template T - The type of SelectMenuDefaultValueType. * @param ids - The IDs of items to be mapped as default. * @param type - The type of default values. * @returns An array of default values. */ function mappedDefault( ids: RestOrArray, type: T, ): APISelectMenuDefaultValue[] { return ids.flat().map(id => ({ id, type })); } /** * Represents a base class for building Select Menus. * @template Select - The type of APISelectMenuComponent. * @template Interaction - The type of interaction. * @example * const selectMenu = new SelectMenu(); * selectMenu.setCustomId("user-select-menu"); * selectMenu.setPlaceholder("Select a user"); * selectMenu.run((interaction) => { * // Handle select menu interaction * }); */ export class SelectMenu< Select extends APISelectMenuComponent = APISelectMenuComponent, //@ts-expect-error Interaction = ComponentInteraction, > extends BaseComponentBuilder