Interface SelectMenu
- All Superinterfaces:
ActionComponent
,ActionRowChildComponent
,Component
,IDisableable
- All Known Subinterfaces:
EntitySelectMenu
,StringSelectMenu
- All Known Implementing Classes:
EntitySelectMenuImpl
,SelectMenuImpl
,StringSelectMenuImpl
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 class
SelectMenu.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 int
The maximum length a select menu id can havestatic final int
The maximum amount of options a select menu can havestatic final int
The maximum length a select menu placeholder can have -
Method Summary
Modifier and TypeMethodDescriptiondefault SelectMenu
Returns a copy of this component withActionComponent.isDisabled()
set to true.default SelectMenu
Returns a copy of this component withActionComponent.isDisabled()
set to false.SelectMenu.Builder
<? extends SelectMenu, ? extends SelectMenu.Builder<?, ?>> Creates a new preconfiguredSelectMenu.Builder
with the same settings used for this select menu.An unique component ID ornull
.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.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
getId, isDisabled
Methods inherited from interface net.dv8tion.jda.api.components.Component
getType, getUniqueId, isMessageCompatible, isModalCompatible
Methods 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:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to the provided value.- Specified by:
withDisabled
in interfaceActionComponent
- Specified by:
withDisabled
in interfaceIDisableable
- Parameters:
disabled
- True, if this component should be disabled- Returns:
- New enabled/disabled component instance
- See Also:
-
asDisabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to true.- Specified by:
asDisabled
in interfaceActionComponent
- Specified by:
asDisabled
in interfaceIDisableable
- Returns:
- New disabled component instance
- See Also:
-
asEnabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to false.- Specified by:
asEnabled
in interfaceActionComponent
- Specified by:
asEnabled
in interfaceIDisableable
- Returns:
- New enabled component instance
- See Also:
-
withUniqueId
Description copied from interface:Component
Creates 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:
withUniqueId
in interfaceActionComponent
- Specified by:
withUniqueId
in interfaceActionRowChildComponent
- Specified by:
withUniqueId
in interfaceComponent
- Specified by:
withUniqueId
in interfaceIDisableable
- Parameters:
uniqueId
- The new ID; must be higher or equal to 1- Returns:
- The new component
-
getCustomId
Description copied from interface:ActionComponent
An 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 usingComponentTree
orIReplaceable.replace(ComponentReplacer)
.- Specified by:
getCustomId
in interfaceActionComponent
- 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
-
createCopy
@Nonnull @CheckReturnValue SelectMenu.Builder<? extends SelectMenu,? extends SelectMenu.Builder<?, createCopy()?>> Creates a new preconfiguredSelectMenu.Builder
with 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.Builder
used to create the select menu
-