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

java.lang.Object
net.dv8tion.jda.api.interactions.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 Summary Link icon

    Modifier and Type
    Method
    Description
    abstract T
    Creates a new SelectMenu instance if all requirements are satisfied.
    The custom id used to identify the select menu.
    int
    The maximum amount of values a user can select at once.
    int
    The minimum amount of values a user has to select.
    Placeholder which is displayed when no selections have been made yet.
    boolean
    Whether the menu is disabled
    setDisabled(boolean disabled)
    Configure whether this select menu should be disabled.
    setId(String customId)
    Change the custom id used to identify the select menu.
    setMaxValues(int maxValues)
    The maximum amount of values a user can select.
    setMinValues(int minValues)
    The minimum amount of values a user has to select.
    setPlaceholder(String placeholder)
    Configure the placeholder which is displayed when no selections have been made yet.
    setRequiredRange(int min, int max)
    The minimum and maximum amount of values a user can select.

    Methods inherited from class java.lang.Object Link icon

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details Link icon

    • setId Link icon

      @Nonnull public B setId(@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
    • setPlaceholder Link icon

      @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 Link icon

      @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 Link icon

      @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 Link icon

      @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 Link icon

      @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 Link icon

      @Nonnull public String getId()
      The custom id used to identify the select menu.
      Returns:
      The custom id
    • getPlaceholder Link icon

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

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

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

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

      @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()