Class SelectMenu.Builder<T extends SelectMenu,B extends SelectMenu.Builder<T,B>>

java.lang.Object
net.dv8tion.jda.api.components.selections.SelectMenu.Builder<T,B>
Type Parameters:
T - The output type
B - The builder type (used for fluent interface)
Direct Known Subclasses:
EntitySelectMenu.Builder, StringSelectMenu.Builder
Enclosing interface:
SelectMenu

public abstract static class SelectMenu.Builder<T extends SelectMenu,B extends SelectMenu.Builder<T,B>> extends Object
A preconfigured builder for the creation of select menus.
  • Method Details

    • setId

      @Nonnull @Deprecated @ReplaceWith("setCustomId(customId)") public B setId(@Nonnull String customId)
      Deprecated.
      Replaced with setCustomId(String)
      Change the custom id used to identify the select menu.
      Parameters:
      customId - The new custom id to use
      Returns:
      The same builder instance for chaining
      Throws:
      IllegalArgumentException - If the provided id is null, empty, or longer than 100 characters
    • setCustomId

      @Nonnull public B setCustomId(@Nonnull String customId)
      Change the custom id used to identify the select menu.
      Parameters:
      customId - The new custom id to use
      Returns:
      The same builder instance for chaining
      Throws:
      IllegalArgumentException - If the provided id is null, empty, or longer than 100 characters
    • setUniqueId

      @Nonnull public B setUniqueId(int uniqueId)
      Changes the numeric ID used to identify the select menu.
      Parameters:
      uniqueId - The new ID, must not be negative
      Returns:
      The same builder instance for chaining
      Throws:
      IllegalArgumentException - If the ID is negative
    • setPlaceholder

      @Nonnull public B setPlaceholder(@Nullable String placeholder)
      Configure the placeholder which is displayed when no selections have been made yet.
      Parameters:
      placeholder - The placeholder or null
      Returns:
      The same builder instance for chaining
      Throws:
      IllegalArgumentException - If the provided placeholder is empty or longer than 100 characters
    • setMinValues

      @Nonnull public B setMinValues(int minValues)
      The minimum amount of values a user has to select.
      Default: 1

      The minimum must not exceed the amount of available options.

      Parameters:
      minValues - The min values
      Returns:
      The same builder instance for chaining
      Throws:
      IllegalArgumentException - If the provided amount is negative or greater than 25
    • setMaxValues

      @Nonnull public B setMaxValues(int maxValues)
      The maximum amount of values a user can select.
      Default: 1

      The maximum must not exceed the amount of available options.

      Parameters:
      maxValues - The max values
      Returns:
      The same builder instance for chaining
      Throws:
      IllegalArgumentException - If the provided amount is less than 1 or greater than 25
    • setRequiredRange

      @Nonnull public B setRequiredRange(int min, int max)
      The minimum and maximum amount of values a user can select.
      Default: 1 for both

      The minimum or maximum must not exceed the amount of available options.

      Parameters:
      min - The min values
      max - The max values
      Returns:
      The same builder instance for chaining
      Throws:
      IllegalArgumentException - If the provided amount is not a valid range (0 <= min <= max)
    • setDisabled

      @Nonnull public B setDisabled(boolean disabled)
      Configure whether this select menu should be disabled.
      Default: false
      Parameters:
      disabled - Whether this menu is disabled
      Returns:
      The same builder instance for chaining
    • getId

      @Nonnull @Deprecated @ForRemoval @ReplaceWith("getCustomId()") public String getId()
      Deprecated.
      Replaced with getCustomId()
      The custom id used to identify the select menu.
      Returns:
      The custom id
    • getCustomId

      @Nonnull public String getCustomId()
      The custom id used to identify the select menu.
      Returns:
      The custom id
    • getUniqueId

      public int getUniqueId()
      The numeric id used to identify the select menu.
      Returns:
      The numeric id
    • getPlaceholder

      @Nullable public String getPlaceholder()
      Placeholder which is displayed when no selections have been made yet.
      Returns:
      The placeholder or null
    • getMinValues

      public int getMinValues()
      The minimum amount of values a user has to select.
      Returns:
      The min values
    • getMaxValues

      public int getMaxValues()
      The maximum amount of values a user can select at once.
      Returns:
      The max values
    • isDisabled

      public boolean isDisabled()
      Whether the menu is disabled
      Returns:
      True if this menu is disabled
    • build

      @Nonnull public abstract T build()
      Creates a new SelectMenu instance if all requirements are satisfied.
      Returns:
      The new SelectMenu instance
      Throws:
      IllegalArgumentException - Throws if getMinValues() is greater than getMaxValues()