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 typeB
- 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 TypeMethodDescriptionabstract T
build()
Creates a newSelectMenu
instance if all requirements are satisfied.getId()
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 disabledsetDisabled
(boolean disabled) Configure whether this select menu should be disabled.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.
-
Method Details
-
setId
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
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
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
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
The minimum and maximum amount of values a user can select.
Default:1
for bothThe minimum or maximum must not exceed the amount of available options.
- Parameters:
min
- The min valuesmax
- 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
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
The custom id used to identify the select menu.- Returns:
- The custom id
-
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
Creates a newSelectMenu
instance if all requirements are satisfied.- Returns:
- The new
SelectMenu
instance - Throws:
IllegalArgumentException
- Throws ifgetMinValues()
is greater thangetMaxValues()
-