dpp::command_option
dpp::json_interface< command_option >
appcommand.h
struct friend struct json_interface< command_option > json_interface< command_option > dpp::command_option::json_interface< command_option > json_interface< command_option >
bool bool dpp::command_option::autocomplete autocomplete dpp::command_option::autocomplete

Does this option supports auto completion?

std::vector< channel_type > std::vector<channel_type> dpp::command_option::channel_types channel_types dpp::command_option::channel_types

Allowed channel types for channel snowflake id options.

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

List of choices for multiple choice command.

std::string std::string dpp::command_option::description description dpp::command_option::description

Option description (1-100 chars).

std::map< std::string, std::string > std::map<std::string, std::string> dpp::command_option::description_localizations description_localizations dpp::command_option::description_localizations

Localisations of command description.

bool bool dpp::command_option::focused focused dpp::command_option::focused

Is the user is typing in this field?

This is sent via autocomplete.

command_option_range command_option_range dpp::command_option::max_value max_value dpp::command_option::max_value

Maximum value/length that can be entered, for dpp::co_number, dpp::co_integer and dpp::co_string types only.

command_option_range command_option_range dpp::command_option::min_value min_value dpp::command_option::min_value

Minimum value/length that can be entered, for dpp::co_number, dpp::co_integer and dpp::co_string types only.

std::string std::string dpp::command_option::name name dpp::command_option::name

Option name (1-32 chars).

std::map< std::string, std::string > std::map<std::string, std::string> dpp::command_option::name_localizations name_localizations dpp::command_option::name_localizations

Localisations of command name.

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

An array of sub-commands (options).

bool bool dpp::command_option::required required dpp::command_option::required

Is this a mandatory parameter?

command_option_type command_option_type dpp::command_option::type type dpp::command_option::type

Option type (what type of value is accepted).

command_value command_value dpp::command_option::value value dpp::command_option::value

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

command_option & command_option & dpp::command_option::fill_from_json_impl (nlohmann::json *j) fill_from_json_impl dpp::command_option::fill_from_json_impl nlohmann::json * j

Fill object properties from JSON. Fills options recursively.

j

JSON to fill from

command_option& Reference to self

dpp::command_option::command_option
()=default
command_option
dpp::command_option::command_option

Construct a new command option object.

dpp::command_option::command_option
(command_option_type t, const std::string &name, const std::string &description, bool required=false)
command_option
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.

t

Option type

name

Option name

description

Option description

required

True if this is a mandatory parameter

virtual dpp::command_option::~command_option
()=default
~command_option
dpp::command_option::~command_option

Destroy the command option object.

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

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

ch

type to set

command_option& return a reference to self for chaining of calls

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

Add a multiple choice option.

o

choice to add

command_option& returns a reference to self for chaining of calls

dpp::logic_exception

command_option is an autocomplete, so choices cannot be added

command_option & command_option & dpp::command_option::add_localization (const std::string &language, const std::string &_name, const std::string &_description="") add_localization 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.

https://discord.com/developers/docs/reference#locales

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 (optional)

command_option& reference to self for fluent chaining

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

Add a sub-command option.

o

Sub-command option to add

command_option& return a reference to self for chaining of calls

std::string std::string dpp::json_interface< command_option >::build_json (bool with_id=false) const build_json dpp::json_interface< command_option >::build_json bool with_id false

Convert object to json string.

with_id

Whether to include the ID or not

Some fields are conditionally filled, do not rely on all fields being present

std::string Json built from the structure

command_option & command_option & dpp::json_interface< command_option >::fill_from_json (nlohmann::json *j) fill_from_json dpp::json_interface< command_option >::fill_from_json nlohmann::json * j

Convert object from nlohmann::json.

j

nlohmann::json object

T& Reference to self for fluent calling

command_option & command_option & dpp::command_option::set_auto_complete (bool autocomp) set_auto_complete dpp::command_option::set_auto_complete bool autocomp

Set the auto complete state.

autocomp

True to enable auto completion for this option

command_option& return a reference to self for chaining of calls

dpp::logic_exception

You attempted to enable auto complete on a command_option that has choices added to it

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

Set the maximum string length of the option. Must be between 1 and 6000 (inclusive). Only valid if the type is dpp::co_string.

max_v

Maximum value

command_option& returns a reference to self for chaining of calls

command_option & command_option & dpp::command_option::set_max_value (command_option_range max_v) set_max_value 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 dpp::co_number or dpp::co_integer.

max_v

Maximum value

command_option& returns a reference to self for chaining of calls

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

Set the minimum string length of the option. Must be between 0 and 6000 (inclusive). Only valid if the type is dpp::co_string.

min_v

Minimum value

command_option& returns a reference to self for chaining of calls

command_option & command_option & dpp::command_option::set_min_value (command_option_range min_v) set_min_value 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 dpp::co_number or dpp::co_integer.

min_v

Minimum value

command_option& returns a reference to self for chaining of calls

auto auto dpp::json_interface< command_option >::to_json (bool with_id=false) const to_json dpp::json_interface< command_option >::to_json bool with_id false

Convert object to nlohmann::json.

with_id

Whether to include the ID or not

Some fields are conditionally filled, do not rely on all fields being present

json Json built from the structure

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.

dpp::command_option
dpp::json_interface< T >
dpp::json_interface< command_option >
< command_option >
K
T
bool
channel_type
command_option_type
dpp::command_option
type
description
name
autocomplete
focused
required
value
choices
options
channel_types
max_value
min_value
description_localizations
name_localizations
dpp::command_option_choice
name
value
name_localizations
dpp::json_interface< T >
dpp::json_interface< command_option >
< command_option >
dpp::json_interface< command_option_choice >
< command_option_choice >
std::basic_string< Char >
std::map< K, T >
keys
elements
std::map< std::string, std::string >
elements
keys
< std::string, std::string >
std::string
variant< std::monostate, int64_t, double >
variant< std::monostate, std::string, int64_t, bool, snowflake, double >
std::vector< T >
elements
std::vector< channel_type >
elements
< channel_type >
std::vector< dpp::command_option >
elements
< dpp::command_option >
std::vector< dpp::command_option_choice >
elements
< dpp::command_option_choice >
- dpp::command_option
  add_channel_type
- dpp::command_option
  add_choice
- dpp::command_option
  add_localization
- dpp::command_option
  add_option
- dpp::command_option
  autocomplete
- dpp::command_option
  build_json
- dpp::command_option
  channel_types
- dpp::command_option
  choices
- dpp::command_option
  command_option
- dpp::command_option
  command_option
- dpp::command_option
  description
- dpp::command_option
  description_localizations
- dpp::command_option
  fill_from_json
- dpp::command_option
  fill_from_json_impl
- dpp::command_option
  focused
- dpp::command_option
  json_interface< command_option >
- dpp::command_option
  max_value
- dpp::command_option
  min_value
- dpp::command_option
  name
- dpp::command_option
  name_localizations
- dpp::command_option
  options
- dpp::command_option
  required
- dpp::command_option
  set_auto_complete
- dpp::command_option
  set_max_length
- dpp::command_option
  set_max_value
- dpp::command_option
  set_min_length
- dpp::command_option
  set_min_value
- dpp::command_option
  to_json
- dpp::command_option
  type
- dpp::command_option
  value
- dpp::command_option
  ~command_option