SelectMenuBuilder class

const selectMenu = new SelectMenuBuilder(data?: object);

constructor

The constructor provides one optional argument which is an object which provides the data for the SelectMenuBuilder class.

The object may contain the following information:

  • custom_id: An id so you can recognize the select menu when an option is selected by a member. The id must be unique and a string between 1-100 characters.

  • options: An array of the options members can choose from in the select menu. The options must be a valid object for the Discord API.

  • placeholder: A string which is shown when no options were selected by the member.

  • min_values: A number which defines the minimum amount of options a member should choose between.

  • max_values: A number which defines the maximum amount of options a member may choose between.

  • disabled: A boolean which defines whether the select menu can be used or not.

  • type: A number which defines the type of component of the seelct menu. (3 means it's a select menu)

Properties

data

An object which makes it a valid object for the Discord API.

{
    custom_id?: string;
    options: [object];
    placeholder?: string;
    min_values: number;
    max_values: number;
    disabled: boolean;
    type: number;
}

Functions

setCustomId

selectMenu.setCustomId(customId: string) : SelectMenuBuilder;

Sets a custom id for the select menu which will be returned to the bot once the an option was selected in the select menu by a member and makes you able to recognize the select menu. The function returns the same SelectMenuBuilder class so you don't have to declare it everytime again.

ArgumentDescription

customId

A string of max 100 characters which will be returned to the bot in the menuSelect event so you can recognize the select menu where the options were selected by the member.

setPlaceholder

selectMenu.setPlaceholder(placeholder: string) : SelectMenuBuilder;

Sets a placeholder for the select menu which is visible for the members when no options were selected. The function returns the same SelectMenuBuilder class so you don't have to declare it everytime again.

ArgumentDescription

placeholder

A string of max 100 characters which should be the placeholder for the select menu.

setDisabled

selectMenu.setDisabled(disabled?: boolean) : SelectMenuBuilder;

Defines whether the options in the select menu may be selected by a member or not. The function returns the same SelectMenuBuilder class so you don't have to declare it everytime again.

ArgumentDescription

disabled

A boolean which defines whether the select menu should be disabled or the options may be selected by a member.

setMinValues

selectMenu.setMinValues(value: number) : SelectMenuBuilder;

Sets the minimum amount of options which a member should select from the select menu builder. The function returns the same SelectMenuBuilder class so you don't have to declare it everytime again.

ArgumentDescription

value

A number which defines the minimum amount of options which a member should select in the select menu.

setMaxValues

selectMenu.setMaxValues(value: number) : SelectMenuBuilder;

Sets the maximum amount of options which a member may select from the select menu builder. The function returns the same SelectMenuBuilder class so you don't have to declare it everytime again.

ArgumentDescription

value

A number which defines the maximum amount of options which a member may select in the select menu.

setOptions

selectMenu.setOptions(...options: [SelectMenuOptionBuilder]) : SelectMenuBuilder;

Adds the options which the member can choose between. The options have to be an instance of the SelectMenuOptionBuilder class. The function returns the same SelectMenuBuilder class so you don't have to declare it everytime again.

ArgumentDescription

options

An array or multiple arguments which all are instances of the SelectMenuOptionBuilder class and define the options which the members can choose between in the select menu.

toJSON

Converts the SelectMenuBuilder class to an object to make it a valid object for the Discord API. The function returns the same data as the data property.

{
    custom_id?: string;
    options: [object];
    placeholder?: string;
    min_values: number;
    max_values: number;
    disabled: boolean;
    type: number;
}

Last updated