Class OptionMapping
CommandInteraction
option.
Since values for command options are a union-type you can use this class to coerce the values to the desired target type.
You can use getType()
to do dynamic handling as well. Each getter documents the conditions and coercion rules for the specific types.
-
Constructor Summary
ConstructorDescriptionOptionMapping
(DataObject data, gnu.trove.map.TLongObjectMap<Object> resolved) -
Method Summary
Modifier and TypeMethodDescriptionboolean
The resolvedAudioChannel
for this option value.boolean
The boolean value.double
The double value for this option.The resolvedGuildChannel
for this option value.long
The long value for this option.The resolvedMember
for this option value.The resolvedIMentionable
instance for this option value.The resolvedGuildMessageChannel
for this option value.The resolvedNewsChannel
for this option value.The resolvedRole
for this option value.The resolvedStageChannel
for this option value.The String representation of this option value.The resolvedTextChannel
for this option value.The resolvedThreadChannel
for this option value.The resolvedUser
for this option value.The resolvedVoiceChannel
for this option value.TheChannelType
for the resolved channel.ResolvedGuildChannel
mentions for aSTRING
option.getName()
The name of this option.getType()
TheOptionType
of this option.int
hashCode()
toString()
-
Constructor Details
-
OptionMapping
-
-
Method Details
-
getMentionedMembers
ResolvedMember
mentions for aSTRING
option.
If this option is not of typeSTRING
, this always returns an empty list. Mentions are sorted by occurrence.This only contains members of the guild. If the user mentions users from other guilds, they will only be provided by
getMentionedUsers()
.This is not supported for
CommandAutoCompleteInteraction
. -
getMentionedUsers
ResolvedUser
mentions for aSTRING
option.
If this option is not of typeSTRING
, this always returns an empty list. Mentions are sorted by occurrence.This may also contain users which are not members in the guild!
This is not supported for
CommandAutoCompleteInteraction
. -
getMentionedRoles
ResolvedRole
mentions for aSTRING
option.
If this option is not of typeSTRING
, this always returns an empty list. Mentions are sorted by occurrence.This is not supported for
CommandAutoCompleteInteraction
. -
getMentionedChannels
ResolvedGuildChannel
mentions for aSTRING
option.
If this option is not of typeSTRING
, this always returns an empty list. Mentions are sorted by occurrence.This is not supported for
CommandAutoCompleteInteraction
.- Returns:
List
ofGuildChannel
the resolved guild channel mentions in a string option
-
getMentions
All resolvedmentions
for aSTRING
option.
If this option is not of typeSTRING
, this always returns an empty list. Mentions are sorted by occurrence.This is not supported for
CommandAutoCompleteInteraction
. This mergesgetMentionedUsers()
,getMentionedMembers()
,getMentionedRoles()
, andgetMentionedChannels()
.- Returns:
List
ofIMentionable
the resolved mentions in a string option
-
getType
TheOptionType
of this option.- Returns:
- The
OptionType
-
getName
The name of this option.- Returns:
- The option name
-
getAsString
The String representation of this option value.
This will automatically convert the value to a string if the type is notOptionType.STRING
.
This will be the ID of any resolved entity such asRole
orMember
.- Returns:
- The String representation of this option value
-
getAsBoolean
public boolean getAsBoolean()The boolean value.- Returns:
- The boolean value
- Throws:
IllegalStateException
- If this option is not of typeBOOLEAN
-
getAsLong
public long getAsLong()- Returns:
- The long value
- Throws:
IllegalStateException
- If this optiontype
cannot be converted to a longNumberFormatException
- If this option is of typeSTRING
and could not be parsed to a valid long value
-
getAsDouble
public double getAsDouble()The double value for this option.- Returns:
- The double value
- Throws:
IllegalStateException
- If this optiontype
cannot be converted to a doubleNumberFormatException
- If this option is of typeSTRING
and could not be parsed to a valid double value
-
getAsMentionable
The resolvedIMentionable
instance for this option value.- Returns:
- The resolved
IMentionable
- Throws:
IllegalStateException
- If the mentioned entity is not resolvable
-
getAsMember
The resolvedMember
for this option value.
Note thatOptionType.USER
can also accept users that are not members of a guild, in which case this will be null!- Returns:
- The resolved
Member
, or null - Throws:
IllegalStateException
- If this option is not of typeUSER
orMENTIONABLE
-
getAsUser
The resolvedUser
for this option value.- Returns:
- The resolved
User
- Throws:
IllegalStateException
- If this option is not of typeUSER
orMENTIONABLE
without a resolved user
-
getAsRole
The resolvedRole
for this option value.- Returns:
- The resolved
Role
- Throws:
IllegalStateException
- If this option is not of typeROLE
orMENTIONABLE
without a resolved role
-
getChannelType
TheChannelType
for the resolved channel.- Returns:
- The
ChannelType
- Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
getAsGuildChannel
The resolvedGuildChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
GuildChannel
- Throws:
IllegalStateException
- If this option is not of typeCHANNEL
or could not be resolved for unexpected reasons
-
getAsMessageChannel
The resolvedGuildMessageChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
GuildMessageChannel
, or null if this was not a message channel - Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
getAsTextChannel
The resolvedTextChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
TextChannel
, or null if this was not a text channel - Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
getAsNewsChannel
The resolvedNewsChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
NewsChannel
, or null if this was not a news channel - Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
getAsThreadChannel
The resolvedThreadChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
ThreadChannel
, or null if this was not a thread channel - Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
getAsAudioChannel
The resolvedAudioChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
AudioChannel
, or null if this was not an audio channel - Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
getAsVoiceChannel
The resolvedVoiceChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
VoiceChannel
, or null if this was not a voice channel - Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
getAsStageChannel
The resolvedStageChannel
for this option value.
Note thatOptionType.CHANNEL
can accept channels of any type!- Returns:
- The resolved
StageChannel
, or null if this was not a stage channel - Throws:
IllegalStateException
- If this option is not of typeCHANNEL
-
toString
-
hashCode
public int hashCode() -
equals
-