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

An option for a select component. More...

#include "message.h"

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

Public Member Functions

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

Public Attributes

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

Protected Member Functions

select_optionfill_from_json_impl (nlohmann::json *j)
 Read class values from json object. More...
 

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 ( const std::string &  label,
const std::string &  value,
const std::string &  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

References dpp::cot_channel_selectmenu, dpp::cot_mentionable_selectmenu, dpp::cot_role_selectmenu, dpp::cot_selectmenu, dpp::cot_text, dpp::cot_user_selectmenu, and dpp::utility::utf8substr().

Here is the call graph for this function:

◆ 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 ( const std::string &  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 ( const std::string &  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 ( const std::string &  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

References dpp::managed::id, dpp::unicode_emoji::id, and dpp::emoji::name.

◆ set_value()

select_option & dpp::select_option::set_value ( const std::string &  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.


The documentation for this struct was generated from the following files: