Interface SelectMenu
- All Superinterfaces:
ActionComponent,ActionRowChildComponent,Component,ICustomId,IDisableable,LabelChildComponent
- All Known Subinterfaces:
EntitySelectMenu,StringSelectMenu
This is an interactive component and usually located within an
ActionRow.
One select menu fills up an entire action row by itself. You cannot have an action row with other components if a select menu is present in the same row.
The selections a user makes are only visible within their current client session. Other users cannot see the choices selected, and they will disappear when the client restarts or the message is reloaded.
This is a generic interface for all types of select menus.
You can use EntitySelectMenu.create(String, Collection) to create a select menu of Discord entities such as users.
Alternatively, you can use StringSelectMenu.create(String) to create a select menu of up to 25 pre-defined strings to pick from.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classSelectMenu.Builder<T extends SelectMenu,B extends SelectMenu.Builder<T, B>> A preconfigured builder for the creation of select menus.Nested classes/interfaces inherited from interface net.dv8tion.jda.api.components.Component
Component.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length a select menu id can havestatic final intThe maximum amount of options a select menu can havestatic final intThe maximum length a select menu placeholder can have -
Method Summary
Modifier and TypeMethodDescriptiondefault SelectMenuReturns a copy of this component withActionComponent.isDisabled()set to true.default SelectMenuReturns a copy of this component withActionComponent.isDisabled()set to false.SelectMenu.Builder<? extends SelectMenu, ? extends SelectMenu.Builder<?, ?>> Creates a new preconfiguredSelectMenu.Builderwith the same settings used for this select menu.An unique component ID ornull.intThe maximum amount of values a user can select at once.intThe minimum amount of values a user has to select.Placeholder which is displayed when no selections have been made yet.Whether the user must populate this select menu in Modals, ornullif not set.withDisabled(boolean disabled) Returns a copy of this component withActionComponent.isDisabled()set to the provided value.withUniqueId(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from interface net.dv8tion.jda.api.components.ActionComponent
isDisabledMethods inherited from interface net.dv8tion.jda.api.components.Component
getType, getUniqueId, isMessageCompatible, isModalCompatibleMethods inherited from interface net.dv8tion.jda.api.components.attribute.IDisableable
isEnabled
-
Field Details
-
ID_MAX_LENGTH
static final int ID_MAX_LENGTHThe maximum length a select menu id can have- See Also:
-
PLACEHOLDER_MAX_LENGTH
static final int PLACEHOLDER_MAX_LENGTHThe maximum length a select menu placeholder can have- See Also:
-
OPTIONS_MAX_AMOUNT
static final int OPTIONS_MAX_AMOUNTThe maximum amount of options a select menu can have- See Also:
-
-
Method Details
-
withDisabled
Description copied from interface:ActionComponentReturns a copy of this component withActionComponent.isDisabled()set to the provided value.Note: Components in modals cannot be disabled.
- Specified by:
withDisabledin interfaceActionComponent- Specified by:
withDisabledin interfaceIDisableable- Parameters:
disabled- True, if this component should be disabled- Returns:
- New enabled/disabled component instance
- See Also:
-
asDisabled
Description copied from interface:ActionComponentReturns a copy of this component withActionComponent.isDisabled()set to true.Note: Components in modals cannot be disabled.
- Specified by:
asDisabledin interfaceActionComponent- Specified by:
asDisabledin interfaceIDisableable- Returns:
- New disabled component instance
- See Also:
-
asEnabled
Description copied from interface:ActionComponentReturns a copy of this component withActionComponent.isDisabled()set to false.- Specified by:
asEnabledin interfaceActionComponent- Specified by:
asEnabledin interfaceIDisableable- Returns:
- New enabled component instance
- See Also:
-
withUniqueId
Description copied from interface:ComponentCreates a new component with the provided numeric ID.
If no ID is set, Discord will generate IDs incrementally starting from 1 and will not use existing IDs from the same message/modal.- Specified by:
withUniqueIdin interfaceActionComponent- Specified by:
withUniqueIdin interfaceActionRowChildComponent- Specified by:
withUniqueIdin interfaceComponent- Specified by:
withUniqueIdin interfaceICustomId- Specified by:
withUniqueIdin interfaceIDisableable- Specified by:
withUniqueIdin interfaceLabelChildComponent- Parameters:
uniqueId- The new ID; must be higher or equal to 1- Returns:
- The new component
-
getCustomId
Description copied from interface:ICustomIdAn unique component ID ornull.
Some components such as link buttons don't have this.Custom IDs can contain custom data, this is typically used to pass data between a slash command and your button listener.
While this ID is unique and can be retrieved with
ComponentInteraction.getComponentId(), you should useComponent.getUniqueId()to identify a component in a single message, such as when replacing components usingComponentTreeorIReplaceable.replace(ComponentReplacer).- Specified by:
getCustomIdin interfaceICustomId- Returns:
- The component ID or null if not present
- See Also:
-
getPlaceholder
Placeholder which is displayed when no selections have been made yet.- Returns:
- The placeholder or null
-
getMinValues
int getMinValues()The minimum amount of values a user has to select.- Returns:
- The min values
-
getMaxValues
int getMaxValues()The maximum amount of values a user can select at once.- Returns:
- The max values
-
isRequired
Whether the user must populate this select menu in Modals, ornullif not set.This attribute is completely separate from the value range, for example, you can have an optional select menu with the range set to
[2 ; 5], meaning you accept either 0 options, or, at least 2 but at most 5.- Returns:
- Whether this menu must be populated, or null
-
createCopy
@Nonnull @CheckReturnValue SelectMenu.Builder<? extends SelectMenu,? extends SelectMenu.Builder<?, createCopy()?>> Creates a new preconfiguredSelectMenu.Builderwith the same settings used for this select menu.
This can be useful to create an updated version of this menu without needing to rebuild it from scratch.- Returns:
- The
SelectMenu.Builderused to create the select menu
-