Each command option is a command line parameter. It can have a type (see dpp::command_option_type), a name, a description, can be required or optional, and can have zero or more choices (for multiple choice), plus options. Adding options acts like sub-commands and can contain more options.
More...
#include <appcommand.h>
Each command option is a command line parameter. It can have a type (see dpp::command_option_type), a name, a description, can be required or optional, and can have zero or more choices (for multiple choice), plus options. Adding options acts like sub-commands and can contain more options.
◆ command_option() [1/2]
dpp::command_option::command_option |
( |
| ) |
|
|
default |
Construct a new command option object.
◆ ~command_option()
virtual dpp::command_option::~command_option |
( |
| ) |
|
|
virtualdefault |
Destroy the command option object.
◆ command_option() [2/2]
dpp::command_option::command_option |
( |
command_option_type |
t, |
|
|
const std::string & |
name, |
|
|
const std::string & |
description, |
|
|
bool |
required = false |
|
) |
| |
Construct a new command option object.
- Parameters
-
t | Option type |
name | Option name |
description | Option description |
required | True if this is a mandatory parameter |
◆ add_channel_type()
Add channel type for option (only for co_channel type options)
- Parameters
-
- Returns
- command_option& return a reference to self for chaining of calls
◆ add_choice()
Add a multiple choice option.
- Parameters
-
- Returns
- command_option& returns a reference to self for chaining of calls
- Exceptions
-
◆ add_localization()
command_option & dpp::command_option::add_localization |
( |
const std::string & |
language, |
|
|
const std::string & |
_name, |
|
|
const std::string & |
_description |
|
) |
| |
Add a localisation for this slash command option.
- See also
- https://discord.com/developers/docs/reference#locales
- Parameters
-
language | Name of language, see the list of locales linked to above. |
_name | name of slash command option in the specified language |
_description | description of slash command option in the specified language |
- Returns
- command_option& reference to self for fluent chaining
◆ add_option()
Add a sub-command option.
- Parameters
-
o | Sub-command option to add |
- Returns
- command_option& return a reference to self for chaining of calls
◆ build_json()
Build JSON string from the object.
- Parameters
-
with_id | Include the ID in the JSON |
- Returns
- std::string JSON string version of object
◆ fill_from_json()
command_option & dpp::command_option::fill_from_json |
( |
nlohmann::json * |
j | ) |
|
Fill object properties from JSON. Fills options recursively.
- Parameters
-
- Returns
- command_option& Reference to self
◆ set_auto_complete()
command_option & dpp::command_option::set_auto_complete |
( |
bool |
autocomp | ) |
|
Set the auto complete state.
- Parameters
-
autocomp | True to enable auto completion for this option |
- Returns
- command_option& return a reference to self for chaining of calls
- Exceptions
-
◆ set_max_value()
Set the maximum numeric value of the option. Only valid if the type is co_number or co_integer.
- Parameters
-
- Returns
- command_option& return a reference to sef for chaining of calls
◆ set_min_value()
Set the minimum numeric value of the option. Only valid if the type is co_number or co_integer.
- Parameters
-
- Returns
- command_option& return a reference to sef for chaining of calls
◆ autocomplete
bool dpp::command_option::autocomplete |
True if this option supports auto completion.
◆ channel_types
std::vector<channel_type> dpp::command_option::channel_types |
Allowed channel types for channel snowflake id options.
◆ choices
List of choices for multiple choice command.
◆ description
std::string dpp::command_option::description |
Option description (1-100 chars)
◆ description_localizations
std::map<std::string, std::string> dpp::command_option::description_localizations |
Localisations of command description.
◆ focused
bool dpp::command_option::focused |
True if the user is typing in this field, when sent via autocomplete.
◆ max_value
Maximum value allowed, for co_number and co_integer types only.
◆ min_value
Minimum value allowed, for co_number and co_integer types only.
◆ name
std::string dpp::command_option::name |
◆ name_localizations
std::map<std::string, std::string> dpp::command_option::name_localizations |
Localisations of command name.
◆ options
◆ required
bool dpp::command_option::required |
True if this is a mandatory parameter.
◆ type
Option type (what type of value is accepted)
◆ value
Set only by autocomplete went sent as part of an interaction.