D++ (DPP)
C++ Discord API Bot Library
dpp::command_option Struct Reference

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>

+ Collaboration diagram for dpp::command_option:

Public Member Functions

 command_option ()=default
 Construct a new command option object. More...
 
 command_option (command_option_type t, const std::string &name, const std::string &description, bool required=false)
 Construct a new command option object. More...
 
command_optionadd_choice (const command_option_choice &o)
 Add a multiple choice option. More...
 
command_optionset_min_value (command_option_range min_v)
 Set the minimum numeric value of the option. Only valid if the type is co_number or co_integer. More...
 
command_optionset_max_value (command_option_range max_v)
 Set the maximum numeric value of the option. Only valid if the type is co_number or co_integer. More...
 
command_optionadd_option (const command_option &o)
 Add a sub-command option. More...
 
command_optionadd_channel_type (const channel_type ch)
 Add channel type for option (only for co_channel type options) More...
 
command_optionset_auto_complete (bool autocomp)
 Set the auto complete state. More...
 
command_optionfill_from_json (nlohmann::json *j)
 Fill object properties from JSON. Fills options recursively. More...
 

Public Attributes

command_option_type type
 Option type (what type of value is accepted) More...
 
std::string name
 Option name (1-32 chars) More...
 
std::string description
 Option description (1-100 chars) More...
 
bool required
 True if this is a mandatory parameter. More...
 
bool focused
 True if the user is typing in this field, when sent via autocomplete. More...
 
command_value value
 Set only by autocomplete went sent as part of an interaction. More...
 
std::vector< command_option_choicechoices
 List of choices for multiple choice command. More...
 
bool autocomplete
 True if this option supports auto completion. More...
 
std::vector< command_optionoptions
 Sub-commands. More...
 
std::vector< channel_typechannel_types
 Allowed channel types for channel snowflake id options. More...
 
command_option_range min_value
 Minimum value allowed, for co_number and co_integer types only. More...
 
command_option_range max_value
 Maximum value allowed, for co_number and co_integer types only. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ command_option() [1/2]

dpp::command_option::command_option ( )
default

Construct a new 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
tOption type
nameOption name
descriptionOption description
requiredTrue if this is a mandatory parameter

Member Function Documentation

◆ add_channel_type()

command_option & dpp::command_option::add_channel_type ( const channel_type  ch)

Add channel type for option (only for co_channel type options)

Parameters
chtype to set
Returns
command_option& return a reference to self for chaining of calls

◆ add_choice()

command_option & dpp::command_option::add_choice ( const command_option_choice o)

Add a multiple choice option.

Parameters
ochoice to add
Returns
command_option& returns a reference to self for chaining of calls
Exceptions
dpp::exceptioncommand_option is an autocomplete, so choices cannot be added

◆ add_option()

command_option & dpp::command_option::add_option ( const command_option o)

Add a sub-command option.

Parameters
oSub-command option to add
Returns
command_option& return a reference to self for chaining of calls

◆ fill_from_json()

command_option & dpp::command_option::fill_from_json ( nlohmann::json j)

Fill object properties from JSON. Fills options recursively.

Parameters
jJSON to fill from
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
autocompTrue to enable auto completion for this option
Returns
command_option& return a reference to self for chaining of calls
Exceptions
dpp::exceptionYou attempted to enable auto complete on a command_option that has choices added to it

◆ set_max_value()

command_option & dpp::command_option::set_max_value ( command_option_range  max_v)

Set the maximum numeric value of the option. Only valid if the type is co_number or co_integer.

Parameters
max_vMaximum value
Returns
command_option& return a reference to sef for chaining of calls

◆ set_min_value()

command_option & dpp::command_option::set_min_value ( command_option_range  min_v)

Set the minimum numeric value of the option. Only valid if the type is co_number or co_integer.

Parameters
min_vMinimum value
Returns
command_option& return a reference to sef for chaining of calls

Member Data Documentation

◆ 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

std::vector<command_option_choice> dpp::command_option::choices

List of choices for multiple choice command.

◆ description

std::string dpp::command_option::description

Option description (1-100 chars)

◆ focused

bool dpp::command_option::focused

True if the user is typing in this field, when sent via autocomplete.

◆ max_value

command_option_range dpp::command_option::max_value

Maximum value allowed, for co_number and co_integer types only.

◆ min_value

command_option_range dpp::command_option::min_value

Minimum value allowed, for co_number and co_integer types only.

◆ name

std::string dpp::command_option::name

Option name (1-32 chars)

◆ options

std::vector<command_option> dpp::command_option::options

Sub-commands.

◆ required

bool dpp::command_option::required

True if this is a mandatory parameter.

◆ type

command_option_type dpp::command_option::type

Option type (what type of value is accepted)

◆ value

command_value dpp::command_option::value

Set only by autocomplete went sent as part of an interaction.

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0