| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
dpp::select_option Struct Reference

An option for a select component. More...

`#include <message.h>`

Inheritance diagram for dpp::select_option:
[legend]
Collaboration diagram for dpp::select_option:
[legend]

## Public Member Functions

| select_option ()
| Construct a new select option object.
| select_option (std::string_view label, std::string_view value, std::string_view description="")
| Construct a new select option object.
virtual | ~select_option ()=default
| Destructs the select option object.
std::string | build_json (bool with_id=false) const
| Convert object to json string.
select_option & | fill_from_json (nlohmann::json *j)
| Convert object from nlohmann::json.
select_option & | set_animated (bool anim)
| Set the emoji as animated.
select_option & | set_default (bool def)
| Set the option as default.
select_option & | set_description (std::string_view d)
| Set the description.
select_option & | set_emoji (std::string_view n, dpp::snowflake id=0, bool animated=false)
| Set the emoji.
select_option & | set_label (std::string_view l)
| Set the label.
select_option & | set_value (std::string_view v)
| Set the value.
auto | to_json (bool with_id=false) const
| Convert object to nlohmann::json.

## Public Attributes

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

## Protected Member Functions

select_option & | fill_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 | ( |  | ) |

virtual default

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

  label | Label of option
  value | Value of option
  description | Description of option

## Member Function Documentation

## ◆ build_json()

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

inline inherited

Convert object to json string.

Parameters

  with_id | Whether 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 | ) |

inline inherited

Convert object from nlohmann::json.

Parameters

  j | nlohmann::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

  j | A 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

  anim | true 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

  def | true 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

  d | description 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

  n | emoji name
  id | emoji id for custom emojis
  animated | true 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

  l | the 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

  v | value 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

inline inherited

Convert object to nlohmann::json.

Parameters

  with_id | Whether 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 Symbol 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.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0