Class SelectOption
- java.lang.Object
-
- net.dv8tion.jda.api.interactions.components.selections.SelectOption
-
- All Implemented Interfaces:
SerializableData
public class SelectOption extends Object implements SerializableData
One of the possible options provided in aSelectionMenu
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SelectOption
fromData(DataObject data)
Inverse function fortoData()
which parses the serialized option dataString
getDescription()
The current description for this option.Emoji
getEmoji()
The emoji attached to this option which is shown next to the option in the selection menuString
getLabel()
The current option label which would be shown to the user in the client.String
getValue()
The current option value which is used to identify the selected options inSelectionMenuInteraction.getValues()
.boolean
isDefault()
Whether this option is selected by defaultstatic SelectOption
of(String label, String value)
Creates a new SelectOption instance.DataObject
toData()
SerializedDataObject
for this object.SelectOption
withDefault(boolean isDefault)
Returns a copy of this select option with the changed default.SelectOption
withDescription(String description)
Returns a copy of this select option with the changed description of this option.SelectOption
withEmoji(Emoji emoji)
Returns a copy of this select option with the changed emoji.SelectOption
withLabel(String label)
Returns a copy of this select option with the changed label.SelectOption
withValue(String value)
Returns a copy of this select option with the changed value.
-
-
-
Method Detail
-
of
@Nonnull @CheckReturnValue public static SelectOption of(@Nonnull String label, @Nonnull String value)
Creates a new SelectOption instance.
You can further configure this with the various setters that return new instances.- Parameters:
label
- The label for the option, up to 25 charactersvalue
- The value for the option used to indicate which option was selected withSelectionMenuInteraction.getValues()
, up to 100 characters- Returns:
- The new select option instance
- Throws:
IllegalArgumentException
- If the null is provided, or any of the individual parameter requirements are violated.
-
withLabel
@Nonnull @CheckReturnValue public SelectOption withLabel(@Nonnull String label)
Returns a copy of this select option with the changed label.- Parameters:
label
- The label for the option, up to 25 characters- Returns:
- The new select option instance
- Throws:
IllegalArgumentException
- If the label is null, empty, or longer than 25 characters
-
withValue
@Nonnull @CheckReturnValue public SelectOption withValue(@Nonnull String value)
Returns a copy of this select option with the changed value.- Parameters:
value
- The value for the option used to indicate which option was selected withSelectionMenuInteraction.getValues()
, up to 100 characters- Returns:
- The new select option instance
- Throws:
IllegalArgumentException
- If the label is null, empty, or longer than 100 characters
-
withDescription
@Nonnull @CheckReturnValue public SelectOption withDescription(@Nullable String description)
Returns a copy of this select option with the changed description of this option.
Default:null
- Parameters:
description
- The new description or null to have no description, up to 50 characters- Returns:
- The new select option instance
- Throws:
IllegalArgumentException
- If the provided description is longer than 50 characters
-
withDefault
@Nonnull @CheckReturnValue public SelectOption withDefault(boolean isDefault)
Returns a copy of this select option with the changed default.
Default:false
- Parameters:
isDefault
- Whether this option is selected by default- Returns:
- The new select option instance
-
withEmoji
@Nonnull @CheckReturnValue public SelectOption withEmoji(@Nullable Emoji emoji)
Returns a copy of this select option with the changed emoji.
Default:null
- Parameters:
emoji
- TheEmoji
shown next to this option, or null- Returns:
- The new select option instance
-
getLabel
@Nonnull public String getLabel()
The current option label which would be shown to the user in the client.- Returns:
- The label
-
getValue
@Nonnull public String getValue()
The current option value which is used to identify the selected options inSelectionMenuInteraction.getValues()
.- Returns:
- The option value
-
getDescription
@Nullable public String getDescription()
The current description for this option.- Returns:
- The description
-
isDefault
public boolean isDefault()
Whether this option is selected by default- Returns:
- True, if this option is selected by default
-
getEmoji
@Nullable public Emoji getEmoji()
The emoji attached to this option which is shown next to the option in the selection menu- Returns:
- The attached emoji
-
toData
@Nonnull public DataObject toData()
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
fromData
@Nonnull @CheckReturnValue public static SelectOption fromData(@Nonnull DataObject data)
Inverse function fortoData()
which parses the serialized option data- Parameters:
data
- The serialized option data- Returns:
- The parsed SelectOption instance
- Throws:
ParsingException
- If the data representation is invalidIllegalArgumentException
- If some part of the data has an invalid length or null is provided
-
-