You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After working with numbers in application commands, it was a pain not having a typed value for choice values, as well as values of raw received application interactions. As such, I proposed two new structs
ApplicationCommandOptionValue
This replaces all instances of object for application command option values. This includes in choices, and received interactions.
Internally, it stores all values possible for an option value:
string
boolean
number
user
channel
role
mentionable
attachment
null
Then, you can check if the value is a specific type via the IsX properties. Then, it can be converted to those underlying values via Get methods.
This replaces all instances of double in application commands. This allows users to have more precision, especially when assigning really large long values as min/max values.
Internally, it stores a long, double, and nullable boolean value. This allows for precision via the long part of the numeric value,
and allows for decimals via the double part of the numeric value.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Motivation
After working with numbers in application commands, it was a pain not having a typed value for choice values, as well as values of raw received application interactions. As such, I proposed two new structs
ApplicationCommandOptionValue
This replaces all instances of
object
for application command option values. This includes in choices, and received interactions.Internally, it stores all values possible for an option value:
Then, you can check if the value is a specific type via the
IsX
properties. Then, it can be converted to those underlying values viaGet
methods.For an implementation, see the current implementation in
bonnel-lib
NumericValue
This replaces all instances of
double
in application commands. This allows users to have more precision, especially when assigning really large long values as min/max values.Internally, it stores a long, double, and nullable boolean value. This allows for precision via the long part of the numeric value,
and allows for decimals via the double part of the numeric value.
For an implementation, see the current implementation in
bonnel-lib
Caveats
Benefits
Beta Was this translation helpful? Give feedback.
All reactions