Allow choices to be specified for other application command option types #4352
Unanswered
dshepsis
asked this question in
API Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Application command options are documented here: https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure
One of the fields for options is
choices
, which limits the permitted values shown to the user for the given option. Currently, this field can only be configured forSTRING
,INTEGER
, andNUMBER
option types. I suggest thatchoices
be implemented for theUSER
,CHANNEL
,ROLE
, andMENTIONABLE
option types.The reason for this suggestion is that, currently, when using any of the latter option types, the user is shown a list of all possible options. This is often undesirable if a command is only intended to function with a specific set of options.
For example, consider a bot command which allows a user to assign themselves a role to change their role color. The server may have other roles related to permissions, which wouldn't be relevant to the command. If the command uses a
ROLE
-type option, those other roles would be included in the list alongside the color roles. As a workaround, the command could use theSTRING
option type and set thechoices
field to the list of color roles. However, one of the main benefits of theROLE
option type is that the roles displayed as options to the user have a text color corresponding to their role color.STRING
option choices are always displayed in a normal black/white text color. I don't see any particular reason why we can't have the benefits of both role colors and a limited choices menu.With respect to implementation, the
choices
field currently accepts an array of objects, each with aname
andvalue
field.name
determines the text that appears in the suggested choices menu for the option.value
determines the actual value for that option sent back to the bot. For example, for aSTRING
-type option, a choice could be shown to the user as "Foo" (name), but be sent to the bot as "Bar" (value). In the case of theUSER
,CHANNEL
,ROLE
, andMENTIONABLE
option types,The most obvious implementation would be for the corresponding id to be given in the
value
field, and thename
field to give the name of that user/channel/role. Of course, the name should be determinable from the id, so I would additionally suggest that thename
field be made optional. In the case of theSTRING
,INTEGER
, andNUMBER
option types, omitting thename
of a choice would result in thevalue
being shown to the user in the choice menu instead. In the case of theUSER
,CHANNEL
,ROLE
, andMENTIONABLE
option types, omitting thename
would result in the resolved name corresponding to the given id being shown to the user in the choice menu.Beta Was this translation helpful? Give feedback.
All reactions