Class StringSelectMenu.Builder
java.lang.Object
net.dv8tion.jda.api.interactions.components.selections.SelectMenu.Builder<StringSelectMenu,StringSelectMenu.Builder>
net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu.Builder
- Enclosing interface:
- StringSelectMenu
public static class StringSelectMenu.Builder
extends SelectMenu.Builder<StringSelectMenu,StringSelectMenu.Builder>
A preconfigured builder for the creation of string select menus.
-
Method Summary
Modifier and TypeMethodDescriptionAdds up to 25 possible options to this select menu.Adds up to 25 possible options to this select menu.Adds up to 25 possible options to this select menu.Adds up to 25 possible options to this select menu.addOptions
(Collection<? extends SelectOption> options) Adds up to 25 possible options to this select menu.addOptions
(SelectOption... options) Adds up to 25 possible options to this select menu.build()
Creates a newStringSelectMenu
instance if all requirements are satisfied.Modifiable list of options currently configured in this builder.setDefaultOptions
(Collection<? extends SelectOption> values) Configures which of the currently appliedoptions
should be selected by default.setDefaultOptions
(SelectOption... values) Configures which of the currently appliedoptions
should be selected by default.setDefaultValues
(String... values) Configures which of the currently appliedoptions
should be selected by default.setDefaultValues
(Collection<String> values) Configures which of the currently appliedoptions
should be selected by default.Methods inherited from class net.dv8tion.jda.api.interactions.components.selections.SelectMenu.Builder
getId, getMaxValues, getMinValues, getPlaceholder, isDisabled, setDisabled, setId, setMaxValues, setMinValues, setPlaceholder, setRequiredRange
-
Method Details
-
addOptions
Adds up to 25 possible options to this select menu.- Parameters:
options
- TheSelectOptions
to add- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If the total amount of options is greater than 25 or null is provided- See Also:
-
addOptions
@Nonnull public StringSelectMenu.Builder addOptions(@Nonnull Collection<? extends SelectOption> options) Adds up to 25 possible options to this select menu.- Parameters:
options
- TheSelectOptions
to add- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If the total amount of options is greater than 25 or null is provided- See Also:
-
addOption
Adds up to 25 possible options to this select menu.- Parameters:
label
- The label for the option, up to 100 charactersvalue
- The value for the option used to indicate which option was selected withSelectMenuInteraction.getValues()
, up to 100 characters- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If the total amount of options is greater than 25, invalid null is provided, or any of the individual parameter requirements are violated.
-
addOption
@Nonnull public StringSelectMenu.Builder addOption(@Nonnull String label, @Nonnull String value, @Nonnull Emoji emoji) Adds up to 25 possible options to this select menu.- Parameters:
label
- The label for the option, up to 100 charactersvalue
- The value for the option used to indicate which option was selected withSelectMenuInteraction.getValues()
, up to 100 charactersemoji
- TheEmoji
shown next to this option, or null- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If the total amount of options is greater than 25, invalid null is provided, or any of the individual parameter requirements are violated.
-
addOption
@Nonnull public StringSelectMenu.Builder addOption(@Nonnull String label, @Nonnull String value, @Nonnull String description) Adds up to 25 possible options to this select menu.- Parameters:
label
- The label for the option, up to 100 charactersvalue
- The value for the option used to indicate which option was selected withSelectMenuInteraction.getValues()
, up to 100 charactersdescription
- The description explaining the meaning of this option in more detail, up to 50 characters- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If the total amount of options is greater than 25, invalid null is provided, or any of the individual parameter requirements are violated.
-
addOption
@Nonnull public StringSelectMenu.Builder addOption(@Nonnull String label, @Nonnull String value, @Nullable String description, @Nullable Emoji emoji) Adds up to 25 possible options to this select menu.- Parameters:
label
- The label for the option, up to 100 charactersvalue
- The value for the option used to indicate which option was selected withSelectMenuInteraction.getValues()
, up to 100 charactersdescription
- The description explaining the meaning of this option in more detail, up to 50 charactersemoji
- TheEmoji
shown next to this option, or null- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If the total amount of options is greater than 25, invalid null is provided, or any of the individual parameter requirements are violated.
-
getOptions
Modifiable list of options currently configured in this builder.- Returns:
- The list of
SelectOptions
-
setDefaultValues
Configures which of the currently appliedoptions
should be selected by default.- Parameters:
values
- Theoption values
- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If null is provided
-
setDefaultValues
Configures which of the currently appliedoptions
should be selected by default.- Parameters:
values
- Theoption values
- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If null is provided
-
setDefaultOptions
@Nonnull public StringSelectMenu.Builder setDefaultOptions(@Nonnull Collection<? extends SelectOption> values) Configures which of the currently appliedoptions
should be selected by default.- Parameters:
values
- TheSelectOptions
- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If null is provided
-
setDefaultOptions
Configures which of the currently appliedoptions
should be selected by default.- Parameters:
values
- TheSelectOptions
- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException
- If null is provided
-
build
Creates a newStringSelectMenu
instance if all requirements are satisfied.
A select menu may not have more than 25 options at once.The values for
SelectMenu.Builder.setMinValues(int)
andSelectMenu.Builder.setMaxValues(int)
are bounded by the length ofgetOptions()
. This means they will automatically be adjusted to not be greater thangetOptions().size()
. You can use this to your advantage to easily make a select menu with unlimited options by setting it toSelectMenu.OPTIONS_MAX_AMOUNT
.- Specified by:
build
in classSelectMenu.Builder<StringSelectMenu,
StringSelectMenu.Builder> - Returns:
- The new
StringSelectMenu
instance - Throws:
IllegalArgumentException
-- If
SelectMenu.Builder.getMinValues()
is greater thanSelectMenu.Builder.getMaxValues()
- If no options are provided
- If more than 25 options are provided
- If
-