Package discord4j.core.object.component
Class SelectMenu
- java.lang.Object
-
- discord4j.core.object.component.MessageComponent
-
- discord4j.core.object.component.ActionComponent
-
- discord4j.core.object.component.SelectMenu
-
public class SelectMenu extends ActionComponent
A message select menu.- See Also:
- Select Menus
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SelectMenu.Option
An option displayed in a select menu.-
Nested classes/interfaces inherited from class discord4j.core.object.component.MessageComponent
MessageComponent.Type
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SelectMenu
disabled()
Creates a new select menu with the same data as this one, but disabled.SelectMenu
disabled(boolean value)
Creates a new select menu with the same data as this one, but depending on the value param it may be disabled or not.Set<Channel.Type>
getAllowedChannelTypes()
Returns a set of acceptable channel types the user may select.String
getCustomId()
Gets the select menu's custom id.int
getMaxValues()
Gets the maximum number of options that must be chosen.int
getMinValues()
Gets the minimum number of options that must be chosen.List<SelectMenu.Option>
getOptions()
Gets the options that can be selected in the menu.Optional<String>
getPlaceholder()
Gets the text displayed if no option is selected.Optional<List<String>>
getValues()
Gets the select menu values, if any.boolean
isDisabled()
Gets whether the select menu is disabled (i.e., the user is prevented from selecting any options).static SelectMenu
of(String customId, SelectMenu.Option... options)
Creates a string select menu.static SelectMenu
of(String customId, List<SelectMenu.Option> options)
Creates a string select menu.static SelectMenu
ofChannel(String customId, Channel.Type... channelTypes)
Creates a channel select menu.static SelectMenu
ofChannel(String customId, List<Channel.Type> channelTypes)
Creates a channel select menu.static SelectMenu
ofMentionable(String customId)
Creates a mentionable select menu.static SelectMenu
ofRole(String customId)
Creates a role select menu.static SelectMenu
ofUser(String customId)
Creates a user select menu.SelectMenu
withAllowedChannelTypes(Channel.Type... types)
Creates a new select menu with the same data as this one, but with the given allowed channel types.SelectMenu
withAllowedChannelTypes(Iterable<Channel.Type> types)
Creates a new select menu with the same data as this one, but with the given allowed channel types.SelectMenu
withMaxValues(int maxValues)
Creates a new select menu with the same data as this one, but with the given maximum values.SelectMenu
withMinValues(int minValues)
Creates a new select menu with the same data as this one, but with the given minimum values.SelectMenu
withPlaceholder(String placeholder)
Creates a new select menu with the same data as this one, but with the given placeholder text.-
Methods inherited from class discord4j.core.object.component.MessageComponent
fromData, getData, getType
-
-
-
-
Method Detail
-
of
public static SelectMenu of(String customId, SelectMenu.Option... options)
Creates a string select menu.- Parameters:
customId
- A developer-defined identifier for the select menu.options
- The options that can be selected in the menu.- Returns:
- A select menu with the given data.
-
of
public static SelectMenu of(String customId, List<SelectMenu.Option> options)
Creates a string select menu.- Parameters:
customId
- A developer-defined identifier for the select menu.options
- The options that can be selected in the menu.- Returns:
- A select menu with the given data.
-
ofRole
public static SelectMenu ofRole(String customId)
Creates a role select menu.- Parameters:
customId
- A developer-defined identifier for the select menu.- Returns:
- A select menu with the given data.
-
ofUser
public static SelectMenu ofUser(String customId)
Creates a user select menu.- Parameters:
customId
- A developer-defined identifier for the select menu.- Returns:
- A select menu with the given data.
-
ofMentionable
public static SelectMenu ofMentionable(String customId)
Creates a mentionable select menu.- Parameters:
customId
- A developer-defined identifier for the select menu.- Returns:
- A select menu with the given data.
-
ofChannel
public static SelectMenu ofChannel(String customId, Channel.Type... channelTypes)
Creates a channel select menu.- Parameters:
customId
- A developer-defined identifier for the select menu.channelTypes
- The allowed channel types.- Returns:
- A select menu with the given data.
-
ofChannel
public static SelectMenu ofChannel(String customId, List<Channel.Type> channelTypes)
Creates a channel select menu.- Parameters:
customId
- A developer-defined identifier for the select menu.channelTypes
- The allowed channel types.- Returns:
- A select menu with the given data.
-
getCustomId
public String getCustomId()
Gets the select menu's custom id.- Returns:
- The select menu's custom id.
-
getValues
public Optional<List<String>> getValues()
Gets the select menu values, if any. Can be present with an empty list if no value was selected.- Returns:
- the select menu's value
-
getAllowedChannelTypes
public Set<Channel.Type> getAllowedChannelTypes()
Returns a set of acceptable channel types the user may select. Only applies toMessageComponent.Type.SELECT_MENU_CHANNEL
type menus, if empty, no restriction on channel types is placed.- Returns:
- A set of channel types a user may select. Empty set means no restriction is applied.
-
getPlaceholder
public Optional<String> getPlaceholder()
Gets the text displayed if no option is selected.- Returns:
- The text displayed if no option is selected.
-
getMinValues
public int getMinValues()
Gets the minimum number of options that must be chosen.- Returns:
- The minimum number of options that must be chosen.
-
getMaxValues
public int getMaxValues()
Gets the maximum number of options that must be chosen.- Returns:
- The maximum number of options that must be chosen.
-
getOptions
public List<SelectMenu.Option> getOptions()
Gets the options that can be selected in the menu. List can be empty iftype
of select menu is notMessageComponent.Type.SELECT_MENU
- Returns:
- The options that can be selected in the menu.
-
isDisabled
public boolean isDisabled()
Gets whether the select menu is disabled (i.e., the user is prevented from selecting any options).- Returns:
- Whether the select menu is disabled.
-
disabled
public SelectMenu disabled()
Creates a new select menu with the same data as this one, but disabled.- Returns:
- A new disabled select menu with the same data as this one.
-
disabled
public SelectMenu disabled(boolean value)
Creates a new select menu with the same data as this one, but depending on the value param it may be disabled or not.- Parameters:
value
- True if the select menu should be disabled otherwise False.- Returns:
- A new possibly disabled select menu with the same data as this one.
-
withPlaceholder
public SelectMenu withPlaceholder(String placeholder)
Creates a new select menu with the same data as this one, but with the given placeholder text.- Parameters:
placeholder
- The new placeholder text.- Returns:
- A new select menu with the given placeholder text.
-
withMinValues
public SelectMenu withMinValues(int minValues)
Creates a new select menu with the same data as this one, but with the given minimum values.- Parameters:
minValues
- The new minimum values.- Returns:
- A new select menu with the given minimum values.
-
withMaxValues
public SelectMenu withMaxValues(int maxValues)
Creates a new select menu with the same data as this one, but with the given maximum values.- Parameters:
maxValues
- The new maximum values.- Returns:
- A new select menu with the given maximum values.
-
withAllowedChannelTypes
public SelectMenu withAllowedChannelTypes(Iterable<Channel.Type> types)
Creates a new select menu with the same data as this one, but with the given allowed channel types.- Parameters:
types
- The new allowed channel types.- Returns:
- A new select menu with the given allowed channel types.
-
withAllowedChannelTypes
public SelectMenu withAllowedChannelTypes(Channel.Type... types)
Creates a new select menu with the same data as this one, but with the given allowed channel types.- Parameters:
types
- The new allowed channel types.- Returns:
- A new select menu with the given allowed channel types.
-
-