StringSelectMenuBuilder

export declare class StringSelectMenuBuilder extends BaseSelectMenuBuilder<APIStringSelectComponent>
export declare class StringSelectMenuBuilder extends BaseSelectMenuBuilder<APIStringSelectComponent>
A builder that creates API-compatible JSON data for string select menus.
constructor(data?)
Creates a new select menu from API data.
Example
Creating a select menu from an API data object:
const selectMenu = new StringSelectMenuBuilder({
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 StringSelectMenuBuilder({
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 data:
const selectMenu = new StringSelectMenuBuilder({
custom_id: 'a cool select menu',
})
.setMinValues(1)
.addOptions({
label: 'Catchy',
value: 'catch',
});
const selectMenu = new StringSelectMenuBuilder({
custom_id: 'a cool select menu',
})
.setMinValues(1)
.addOptions({
label: 'Catchy',
value: 'catch',
});
NameTypeOptionalDescription
dataPartial<APIStringSelectComponent>YesThe API data to create this select menu with
ProtectedReadonly
Readonly
The options for this select menu.
addOptions(...options):this
Adds options to this select menu.
NameTypeOptionalDescription
...optionsRestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder | ((builder: StringSelectMenuOptionBuilder) => StringSelectMenuOptionBuilder)>NoThe options to add
clearPlaceholder():this
Clears the placeholder for this select menu.
Inherited from BaseSelectMenuBuilder
setCustomId(customId):this
Sets the custom id for this select menu.
NameTypeOptionalDescription
customIdstringNoThe custom id to use
Inherited from BaseSelectMenuBuilder
setDisabled(disabled?):this
Sets whether this select menu is disabled.
NameTypeOptionalDescription
disabledbooleanYesWhether this select menu is disabled
Inherited from BaseSelectMenuBuilder
setMaxValues(maxValues):this
Sets the maximum values that must be selected in the select menu.
NameTypeOptionalDescription
maxValuesnumberNoThe maximum values that must be selected
Inherited from BaseSelectMenuBuilder
setMinValues(minValues):this
Sets the minimum values that must be selected in the select menu.
NameTypeOptionalDescription
minValuesnumberNoThe minimum values that must be selected
Inherited from BaseSelectMenuBuilder
setOptions(...options):this
Sets the options for this select menu.
NameTypeOptionalDescription
...optionsRestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder | ((builder: StringSelectMenuOptionBuilder) => StringSelectMenuOptionBuilder)>NoThe options to set
setPlaceholder(placeholder):this
Sets the placeholder for this select menu.
NameTypeOptionalDescription
placeholderstringNoThe placeholder to use
Inherited from BaseSelectMenuBuilder
spliceOptions(index, deleteCount, ...options):this
Removes, replaces, or inserts options for this select menu.
Remarks
This method behaves similarly to Array.prototype.splice(). It's useful for modifying and adjusting the order of existing options.
Example
Remove the first option:
selectMenu.spliceOptions(0, 1);
selectMenu.spliceOptions(0, 1);
Example
Remove the first n option:
const n = 4;
selectMenu.spliceOptions(0, n);
const n = 4;
selectMenu.spliceOptions(0, n);
Example
Remove the last option:
selectMenu.spliceOptions(-1, 1);
selectMenu.spliceOptions(-1, 1);
NameTypeOptionalDescription
indexnumberNoThe index to start at
deleteCountnumberNoThe number of options to remove
...options(APISelectMenuOption | StringSelectMenuOptionBuilder | ((builder: StringSelectMenuOptionBuilder) => StringSelectMenuOptionBuilder))[]NoThe replacing option objects or builders
toJSON(validationOverride?):APIStringSelectComponent
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.
NameTypeOptionalDescription
validationOverridebooleanYesForce validation to run/not run regardless of your global preference