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

    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

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

    • setId

      @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

      @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 public String getId()
      The custom id used to identify the select menu.
      Returns:
      The custom 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()