SelectMenuBuilder
declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent>
declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent>
Represents a select menu component
Extends
ComponentBuilder<APISelectMenuComponent>constructor(data?)
Creates a new select menu from API data
Example
Creating a select menu from an API data objectconst selectMenu = new SelectMenuBuilder({
custom_id: 'a cool select menu',
placeholder: 'select an option',
max_values: 2,
options: [
{ label: 'option 1', value: '1' },
{ label: 'option 2', value: '2' },
{ label: 'option 3', value: '3' },
],
});
const selectMenu = new SelectMenuBuilder({
custom_id: 'a cool select menu',
placeholder: 'select an option',
max_values: 2,
options: [
{ label: 'option 1', value: '1' },
{ label: 'option 2', value: '2' },
{ label: 'option 3', value: '3' },
],
});
Example
Creating a select menu using setters and API dataconst selectMenu = new SelectMenuBuilder({
custom_id: 'a cool select menu',
})
.setMinValues(1)
.addOptions({
label: 'Catchy',
value: 'catch',
});
const selectMenu = new SelectMenuBuilder({
custom_id: 'a cool select menu',
})
.setMinValues(1)
.addOptions({
label: 'Catchy',
value: 'catch',
});
Name | Type | Optional | Description |
---|---|---|---|
data | Partial<APISelectMenuComponent> | Yes | The API data to create this select menu with |
Readonly
data
:
Partial<DataType>
The API data associated with this component
Inherited from ComponentBuilderReadonly
The options within this select menu
addOptions(options)
:
this
Adds options to this select menu
Name | Type | Optional | Description |
---|---|---|---|
options | RestOrArray<APISelectMenuOption | SelectMenuOptionBuilder> | No | The options to add to this select menu |
setCustomId(customId)
:
this
Sets the custom id for this select menu
Name | Type | Optional | Description |
---|---|---|---|
customId | string | No | The custom id to use for this select menu |
setDisabled(disabled?)
:
this
Sets whether this select menu is disabled
Name | Type | Optional | Description |
---|---|---|---|
disabled | boolean | Yes | Whether this select menu is disabled |
setMaxValues(maxValues)
:
this
Sets the maximum values that must be selected in the select menu
Name | Type | Optional | Description |
---|---|---|---|
maxValues | number | No | The maximum values that must be selected |
setMinValues(minValues)
:
this
Sets the minimum values that must be selected in the select menu
Name | Type | Optional | Description |
---|---|---|---|
minValues | number | No | The minimum values that must be selected |
setOptions(options)
:
this
Sets the options on this select menu
Name | Type | Optional | Description |
---|---|---|---|
options | RestOrArray<APISelectMenuOption | SelectMenuOptionBuilder> | No | The options to set on this select menu |
setPlaceholder(placeholder)
:
this
Sets the placeholder for this select menu
Name | Type | Optional | Description |
---|---|---|---|
placeholder | string | No | The placeholder to use for this select menu |
toJSON()
:
APISelectMenuComponent
Serializes this component to an API-compatible JSON object