View Source Nostrum.Struct.ApplicationCommand (Nostrum v0.6.0)
Typespecs for creating Application Commands
Official reference: https://discord.com/developers/docs/interactions/application-commands
Link to this section Summary
Types
When editing an existing application command, only the following fields may be updated, missing fields will remain unchanged.
This defines the map for creating an application command.
1forROLE2forUSER
For editing the permissions for an application command
If you specify choices for a command those become the only valid options for the user to select from.
The command, subcommand, or options's description, for CHAT_INPUT commands it must be between 1 and 100 characters in length.
For USER and MESSAGE commands it must be an empty string.
The name of the command, subcommand, or command_option, it must be between 1 and 32 characters in length and match the following regex ^[w-]{1,32}$
Only USER and MESSAGE commands may include uppercase letters and spaces.
This defines a commands parameters, only valid for CHAT_INPUT commands.
Indicates what type of argument the command expects.
The type of application command you wish to create
Link to this section Types
Specs
application_command_edit_map() :: %{
optional(:name) => command_name(),
optional(:description) => command_description(),
optional(:options) => [command_option()],
optional(:default_permission) => boolean()
}
When editing an existing application command, only the following fields may be updated, missing fields will remain unchanged.
Specs
application_command_map() :: %{
:name => command_name(),
:description => command_description(),
optional(:type) => command_type(),
optional(:default_permission) => boolean(),
optional(:options) => [command_option()]
}
This defines the map for creating an application command.
:default_permission is for if the command is enabled for all users by default
For more information see the official documentation
Specs
application_command_permission_type() :: pos_integer()
1forROLE2forUSER
Specs
application_command_permissions() :: %{
id: Nostrum.Snowflake.t(),
type: application_command_permission_type(),
permission: boolean()
}
For editing the permissions for an application command
:idis the id of the role or user:typeis the type of the id, eitherroleoruser:allowis whether the role or user should be allowed to use the command
Specs
If you specify choices for a command those become the only valid options for the user to select from.
Specs
command_description() :: String.t()
The command, subcommand, or options's description, for CHAT_INPUT commands it must be between 1 and 100 characters in length.
For USER and MESSAGE commands it must be an empty string.
Specs
command_name() :: String.t()
The name of the command, subcommand, or command_option, it must be between 1 and 32 characters in length and match the following regex ^[w-]{1,32}$
Only USER and MESSAGE commands may include uppercase letters and spaces.
Specs
command_option() :: %{
:name => command_name(),
:description => command_description(),
:type => command_option_type(),
optional(:required) => boolean(),
optional(:choices) => [command_choice()],
optional(:options) => [command_option()],
optional(:channel_types) => [pos_integer()],
optional(:autocomplete) => boolean()
}
This defines a commands parameters, only valid for CHAT_INPUT commands.
Notes
- required parameters on a command must precede optional ones
- for subcommands and subcommand groups,
:optionsare it's parameters :optionsand:choicesare mutually exclusive:autocompletemay not be set to true if:choicesis present- if
:typeis 7 then:channel_typescan be a list of allowed channel types
Specs
command_option_type() :: 1..10
Indicates what type of argument the command expects.
Specs
command_type() :: pos_integer()
The type of application command you wish to create
1forCHAT_INPUT, regular slash commands (default)2forUSER, right-click menu commands on a specific user3forMESSAGE, right-click menu commands on a specific message