import { APIChannelSelectComponent, APIMentionableSelectComponent, APIMessageComponentEmoji, APIRoleSelectComponent, APISelectMenuComponent, APISelectMenuOption, APIStringSelectComponent, APIUserSelectComponent, ChannelType, ComponentType, TypeArray } from '@biscuitland/common'; import { OptionValuesLength } from '..'; import { BaseComponent } from './BaseComponent'; class SelectMenu { setCustomId(id: string): this { this.data.custom_id = id; return this; } setPlaceholder(placeholder: string): this { this.data.placeholder = placeholder; return this; } setValuesLength({ max, min }: Partial): this { this.data.max_values = max; this.data.min_values = min; return this; } setDisabled(disabled = true): this { this.data.disabled = disabled; return this; } } export class UserSelectMenu extends SelectMenu { constructor(data: Partial = {}) { super({ ...data, type: ComponentType.UserSelect }); } } export class RoleSelectMenu extends SelectMenu { constructor(data: Partial = {}) { super({ ...data, type: ComponentType.RoleSelect }); } } export class MentionableSelectMenu extends SelectMenu { constructor(data: Partial = {}) { super({ ...data, type: ComponentType.MentionableSelect }); } } export class ChannelSelectMenu extends SelectMenu { constructor(data: Partial = {}) { super({ ...data, type: ComponentType.ChannelSelect }); } setChannelTypes(types: ChannelType[]): this { this.data.channel_types = types; return this; } } export class StringSelectMenu extends SelectMenu { constructor(data: Partial = {}) { super({ ...data, type: ComponentType.StringSelect }); } addOption(option: TypeArray): this { this.data.options ??= []; this.data.options = this.data.options.concat(option); return this; } setOptions(options: APISelectMenuOption[]): this { this.data.options = options; return this; } } export class StringSelectOption { // biome-ignore lint/nursery/noEmptyBlockStatements: constructor(public data: Partial = {}) {} setLabel(label: string): this { this.data.label = label; return this; } setValue(value: string): this { this.data.value = value; return this; } setDescription(description: string): this { this.data.description = description; return this; } setDefault(Default = true): this { this.data.default = Default; return this; } setEmoji(emoji: APIMessageComponentEmoji): this { this.data.emoji = emoji; return this; } toJSON(): APISelectMenuOption { return { ...this.data } as APISelectMenuOption; } }