Discord.https - v3.0.16
    Preparing search index...

    Class SelectMenuBuilder

    A builder that creates API-compatible JSON data for string select menus.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new select menu from API data.

      Parameters

      Returns SelectMenuBuilder

      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' },
      ],
      });

      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',
      });

    Properties

    data: Partial<DataType>

    The API data associated with this component.

    The options within this select menu.

    Methods

    • Clears the id of this component, defaulting to a default incremented id.

      Returns this

    • Sets the custom id for this select menu.

      Parameters

      • customId: string

        The custom id to use

      Returns this

    • Sets whether this select menu is disabled.

      Parameters

      • Optionaldisabled: boolean

        Whether this select menu is disabled

      Returns this

    • Sets the id (not the custom id) for this component.

      Parameters

      • id: number

        The id for this component

      Returns this

    • Sets the maximum values that must be selected in the select menu.

      Parameters

      • maxValues: number

        The maximum values that must be selected

      Returns this

    • Sets the minimum values that must be selected in the select menu.

      Parameters

      • minValues: number

        The minimum values that must be selected

      Returns this

    • Sets the placeholder for this select menu.

      Parameters

      • placeholder: string

        The placeholder to use

      Returns this

    • Sets whether this select menu is required.

      Parameters

      • Optionalrequired: boolean

        Whether this select menu is required

      Returns this

      Only for use in modals.

    • Removes, replaces, or inserts options for this select menu.

      Parameters

      Returns this

      This method behaves similarly to Array.prototype.splice(). It's useful for modifying and adjusting the order of existing options.

      Remove the first option:

      selectMenu.spliceOptions(0, 1);
      

      Remove the first n option:

      const n = 4;
      selectMenu.spliceOptions(0, n);

      Remove the last option:

      selectMenu.spliceOptions(-1, 1);