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

An option for a select component. More...

+ Inheritance diagram for dpp::select_option:
+ Collaboration diagram for dpp::select_option:

Public Member Functions

 select_option ()
 Construct a new select option object. More...
 
virtual ~select_option ()=default
 Destructs the select option object. More...
 
 select_option (std::string_view label, std::string_view value, std::string_view description="")
 Construct a new select option object. More...
 
select_optionset_label (std::string_view l)
 Set the label. More...
 
select_optionset_value (std::string_view v)
 Set the value. More...
 
select_optionset_description (std::string_view d)
 Set the description. More...
 
select_optionset_emoji (std::string_view n, dpp::snowflake id=0, bool animated=false)
 Set the emoji. More...
 
select_optionset_default (bool def)
 Set the option as default. More...
 
select_optionset_animated (bool anim)
 Set the emoji as animated. More...
 
select_optionfill_from_json (nlohmann::json *j)
 Convert object from nlohmann::json. More...
 
auto to_json (bool with_id=false) const
 Convert object to nlohmann::json. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. More...
 

Public Attributes

std::string label
 User-facing name of the option. More...
 
std::string value
 Dev-defined value of the option. More...
 
std::string description
 Additional description of the option. More...
 
bool is_default
 True if option is the default option. More...
 
partial_emoji emoji
 The emoji for the select option. More...
 

Protected Member Functions

select_optionfill_from_json_impl (nlohmann::json *j)
 

Friends

struct json_interface< select_option >
 

Detailed Description

An option for a select component.

Constructor & Destructor Documentation

◆ select_option() [1/2]

dpp::select_option::select_option ( )

Construct a new select option object.

◆ ~select_option()

virtual dpp::select_option::~select_option ( )
virtualdefault

Destructs the select option object.

◆ select_option() [2/2]

dpp::select_option::select_option ( std::string_view  label,
std::string_view  value,
std::string_view  description = "" 
)

Construct a new select option object.

Parameters
labelLabel of option
valueValue of option
descriptionDescription of option

Member Function Documentation

◆ build_json()

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

Convert object to json string.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
std::string Json built from the structure

◆ fill_from_json()

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

Convert object from nlohmann::json.

Parameters
jnlohmann::json object
Returns
T& Reference to self for fluent calling

◆ fill_from_json_impl()

select_option& dpp::select_option::fill_from_json_impl ( nlohmann::json *  j)
protected

Read class values from json object

Parameters
jA json object to read from
Returns
A reference to self

◆ set_animated()

select_option& dpp::select_option::set_animated ( bool  anim)

Set the emoji as animated.

Parameters
animtrue if animated
Returns
select_option& reference to self for chaining

◆ set_default()

select_option& dpp::select_option::set_default ( bool  def)

Set the option as default.

Parameters
deftrue to set the option as default
Returns
select_option& reference to self for chaining

◆ set_description()

select_option& dpp::select_option::set_description ( std::string_view  d)

Set the description.

Parameters
ddescription to set. It will be truncated to the maximum length of 100 UTF-8 characters.
Returns
select_option& reference to self for chaining

◆ set_emoji()

select_option& dpp::select_option::set_emoji ( std::string_view  n,
dpp::snowflake  id = 0,
bool  animated = false 
)

Set the emoji.

Parameters
nemoji name
idemoji id for custom emojis
animatedtrue if animated emoji
Returns
select_option& reference to self for chaining

◆ set_label()

select_option& dpp::select_option::set_label ( std::string_view  l)

Set the label.

Parameters
lthe user-facing name of the option. It will be truncated to the maximum length of 100 UTF-8 characters.
Returns
select_option& reference to self for chaining

◆ set_value()

select_option& dpp::select_option::set_value ( std::string_view  v)

Set the value.

Parameters
vvalue to set. It will be truncated to the maximum length of 100 UTF-8 characters.
Returns
select_option& reference to self for chaining

◆ to_json()

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

Convert object to nlohmann::json.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
json Json built from the structure

Friends And Related Function Documentation

◆ json_interface< select_option >

friend struct json_interface< select_option >
friend

Member Data Documentation

◆ description

std::string dpp::select_option::description

Additional description of the option.

◆ emoji

partial_emoji dpp::select_option::emoji

The emoji for the select option.

◆ is_default

bool dpp::select_option::is_default

True if option is the default option.

◆ label

std::string dpp::select_option::label

User-facing name of the option.

◆ value

std::string dpp::select_option::value

Dev-defined value of the option.

D++ 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