Interface EntitySelectMenu
- All Superinterfaces:
ActionComponent
,Component
,ItemComponent
,SelectMenu
,SerializableData
Specialized
SelectMenu
for selecting Discord entities.
Unlike StringSelectMenu
, these entity select menus do not support custom choices.
A user will get suggested inputs based on what they write into the select menu.
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.
Examples
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
if (!event.getName().equals("class")) return;
EntitySelectMenu menu = EntitySelectMenu.create("menu:class", SelectTarget.ROLE)
.setPlaceholder("Choose your class") // shows the placeholder indicating what this menu is for
.setRequiredRange(1, 1) // must select exactly one
.build();
event.reply("Please pick your class below")
.setEphemeral(true)
.addActionRow(menu)
.queue();
}
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
A preconfigured builder for the creation of entity select menus.static class
Represents the default values used ingetDefaultValues()
.static enum
Supported entity types for a EntitySelectMenu.Nested classes/interfaces inherited from interface net.dv8tion.jda.api.interactions.components.Component
Component.Type
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.interactions.components.selections.SelectMenu
ID_MAX_LENGTH, OPTIONS_MAX_AMOUNT, PLACEHOLDER_MAX_LENGTH
-
Method Summary
Modifier and TypeMethodDescriptiondefault EntitySelectMenu
Returns a copy of this component withActionComponent.isDisabled()
set to true.default EntitySelectMenu
Returns a copy of this component withActionComponent.isDisabled()
set to false.static EntitySelectMenu.Builder
create
(String customId, Collection<EntitySelectMenu.SelectTarget> types) Creates a newEntitySelectMenu.Builder
for a select menu with the provided custom id.static EntitySelectMenu.Builder
create
(String customId, EntitySelectMenu.SelectTarget type, EntitySelectMenu.SelectTarget... types) Creates a newEntitySelectMenu.Builder
for a select menu with the provided custom id.default EntitySelectMenu.Builder
Creates a new preconfiguredEntitySelectMenu.Builder
with the same settings used for this select menu.The allowedChannelTypes
for this menu.@Unmodifiable List<EntitySelectMenu.DefaultValue>
Default selected values.TheSelectTargets
supported by this menu.default EntitySelectMenu
withDisabled
(boolean disabled) Returns a copy of this component withActionComponent.isDisabled()
set to the provided value.Methods inherited from interface net.dv8tion.jda.api.interactions.components.ActionComponent
getId, isDisabled
Methods inherited from interface net.dv8tion.jda.api.interactions.components.ItemComponent
getMaxPerRow, isMessageCompatible, isModalCompatible
Methods inherited from interface net.dv8tion.jda.api.interactions.components.selections.SelectMenu
getMaxValues, getMinValues, getPlaceholder
Methods inherited from interface net.dv8tion.jda.api.utils.data.SerializableData
toData
-
Method Details
-
asDisabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to true.- Specified by:
asDisabled
in interfaceActionComponent
- Returns:
- New disabled component instance
-
asEnabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to false.- Specified by:
asEnabled
in interfaceActionComponent
- Returns:
- New enabled component instance
-
withDisabled
Description copied from interface:ActionComponent
Returns a copy of this component withActionComponent.isDisabled()
set to the provided value.- Specified by:
withDisabled
in interfaceActionComponent
- Parameters:
disabled
- True, if this component should be disabled- Returns:
- New enabled/disabled component instance
-
getEntityTypes
TheSelectTargets
supported by this menu.
If the targets includeEntitySelectMenu.SelectTarget.CHANNEL
, then they are also filtered bygetChannelTypes()
.Modifying the returned
EnumSet
will not affect this menu.- Returns:
EnumSet
ofEntitySelectMenu.SelectTarget
-
getChannelTypes
The allowedChannelTypes
for this menu.
This is only relevant if theSelectTargets
includeEntitySelectMenu.SelectTarget.CHANNEL
. The returned set is empty if all types are supported, orgetEntityTypes()
does not includeEntitySelectMenu.SelectTarget.CHANNEL
.Modifying the returned
EnumSet
will not affect this menu.- Returns:
EnumSet
ofChannelType
-
getDefaultValues
Default selected values.
These are shown until the user customizes the selected values, which then fires aEntitySelectInteractionEvent
.- Returns:
- Immutable list of
default values
-
createCopy
Creates a new preconfiguredEntitySelectMenu.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.- Specified by:
createCopy
in interfaceSelectMenu
- Returns:
- The
EntitySelectMenu.Builder
used to create the select menu
-
create
@Nonnull @CheckReturnValue static EntitySelectMenu.Builder create(@Nonnull String customId, @Nonnull Collection<EntitySelectMenu.SelectTarget> types) Creates a newEntitySelectMenu.Builder
for a select menu with the provided custom id.- Parameters:
customId
- The id used to identify this menu withActionComponent.getId()
for component interactionstypes
- The supportedSelectTargets
- Returns:
- The
EntitySelectMenu.Builder
used to create the select menu - Throws:
IllegalArgumentException
-- If the provided id is null, empty, or longer than 100 characters.
- If the provided types are null, empty, or invalid.
-
create
@Nonnull @CheckReturnValue static EntitySelectMenu.Builder create(@Nonnull String customId, @Nonnull EntitySelectMenu.SelectTarget type, @Nonnull EntitySelectMenu.SelectTarget... types) Creates a newEntitySelectMenu.Builder
for a select menu with the provided custom id.- Parameters:
customId
- The id used to identify this menu withActionComponent.getId()
for component interactionstype
- The first supportedEntitySelectMenu.SelectTarget
types
- Other supportedSelectTargets
- Returns:
- The
EntitySelectMenu.Builder
used to create the select menu - Throws:
IllegalArgumentException
-- If the provided id is null, empty, or longer than 100 characters.
- If the provided types are null or invalid.
-