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

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

A rich embed for display within a dpp::message. More...

`#include <message.h>`

Collaboration diagram for dpp::embed:
[legend]

## Public Member Functions

| embed ()
| Constructor.
| embed (nlohmann::json *j)
| Constructor to build embed from json object.
| ~embed ()
| Destructor.
embed & | add_field (std::string_view name, std::string_view value, bool is_inline=false)
| Add an embed field.
embed & | set_author (const dpp::embed_author &a)
| Set embed author.
embed & | set_author (std::string_view name, std::string_view url, std::string_view icon_url)
| Set embed author.
embed & | set_color (uint32_t col)
| Set embed colour.
embed & | set_colour (uint32_t col)
| Set embed colour.
embed & | set_description (std::string_view text)
| Set embed description.
embed & | set_footer (const embed_footer &f)
| Set the footer of the embed.
embed & | set_footer (std::string_view text, std::string_view icon_url)
| Set the footer of the embed.
embed & | set_image (std::string_view url)
| Set embed image.
embed & | set_provider (std::string_view name, std::string_view url)
| Set embed provider.
embed & | set_thumbnail (std::string_view url)
| Set embed thumbnail.
embed & | set_timestamp (time_t tstamp)
| Set embed timestamp.
embed & | set_title (std::string_view text)
| Set embed title.
embed & | set_url (std::string_view url)
| Set embed url.
embed & | set_video (std::string_view url)
| Set embed video.

## Public Attributes

std::optional< embed_author > | author
| Optional: Author information.
std::optional< uint32_t > | color
| Optional: Color code of the embed.
std::string | description
| Optional: Description of embed.
std::vector< embed_field > | fields
| Optional: Fields information.
std::optional< embed_footer > | footer
| Optional: Footer information.
std::optional< embed_image > | image
| Optional: Image information.
std::optional< embed_provider > | provider
| Optional: Provider information.
std::optional< embed_image > | thumbnail
| Optional: Thumbnail information.
time_t | timestamp
| Optional: Timestamp of embed content.
std::string | title
| Optional: Title of embed.
std::string | type
| Optional: Type of embed.
std::string | url
| Optional: URL of embed.
std::optional< embed_image > | video
| Optional: Video information.

## Detailed Description

A rich embed for display within a dpp::message.

## Constructor & Destructor Documentation

## ◆ embed() [1/2]

dpp::embed::embed | ( |  | ) |

Constructor.

## ◆ embed() [2/2]

dpp::embed::embed | ( | nlohmann::json * | j | ) |

Constructor to build embed from json object.

Parameters

  j | JSON to read content from

## ◆ ~embed()

dpp::embed::~embed | ( |  | ) |

Destructor.

## Member Function Documentation

## ◆ add_field()

embed & dpp::embed::add_field | ( | std::string_view | name,
|  | std::string_view | value,
|  | bool | is_inline = false )

Add an embed field.

Parameters

  name | The name of the field. It will be truncated to the maximum length of 256 UTF-8 characters.
  value | The value of the field. It will be truncated to the maximum length of 1024 UTF-8 characters.
  is_inline | Whether or not to display the field 'inline' or on its own line

Returns
  A reference to self so this method may be "chained".

## ◆ set_author() [1/2]

embed & dpp::embed::set_author | ( | const dpp::embed_author & | a | ) |

Set embed author.

Parameters

  a | The author to set

Returns
  A reference to self so this method may be "chained".

## ◆ set_author() [2/2]

embed & dpp::embed::set_author | ( | std::string_view | name,
|  | std::string_view | url,
|  | std::string_view | icon_url )

Set embed author.

Parameters

  name | The name of the author. It will be truncated to the maximum length of 256 UTF-8 characters.
  url | The url of the author (only supports http(s))
  icon_url | The icon URL of the author (only supports http(s) and attachments)

Returns
  A reference to self so this method may be "chained".

## ◆ set_color()

embed & dpp::embed::set_color | ( | uint32_t | col | ) |

Set embed colour.

Parameters

  col | The colour of the embed

Returns
  A reference to self so this method may be "chained".

## ◆ set_colour()

embed & dpp::embed::set_colour | ( | uint32_t | col | ) |

Set embed colour.

Parameters

  col | The colour of the embed

Returns
  A reference to self so this method may be "chained".

## ◆ set_description()

embed & dpp::embed::set_description | ( | std::string_view | text | ) |

Set embed description.

Parameters

  text | The text of the title. It will be truncated to the maximum length of 4096 UTF-8 characters.

Returns
  A reference to self so this method may be "chained".

## ◆ set_footer() [1/2]

embed & dpp::embed::set_footer | ( | const embed_footer & | f | ) |

Set the footer of the embed.

Parameters

  f | the footer to set

Returns
  A reference to self so this method may be "chained".

## ◆ set_footer() [2/2]

embed & dpp::embed::set_footer | ( | std::string_view | text,
|  | std::string_view | icon_url )

Set the footer of the embed.

Parameters

  text | string to set as footer text. It will be truncated to the maximum length of 2048 UTF-8 characters.
  icon_url | an url to set as footer icon url (only supports http(s) and attachments)

Returns
  A reference to self so this method may be "chained".

## ◆ set_image()

embed & dpp::embed::set_image | ( | std::string_view | url | ) |

Set embed image.

Parameters

  url | The embed image URL (only supports http(s) and attachments)

Returns
  A reference to self so this method may be "chained".

## ◆ set_provider()

embed & dpp::embed::set_provider | ( | std::string_view | name,
|  | std::string_view | url )

Set embed provider.

Parameters

  name | The provider name. It will be truncated to the maximum length of 256 UTF-8 characters.
  url | The provider url

Returns
  A reference to self so this method may be "chained".

## ◆ set_thumbnail()

embed & dpp::embed::set_thumbnail | ( | std::string_view | url | ) |

Set embed thumbnail.

Parameters

  url | The embed thumbnail url (only supports http(s) and attachments)

Returns
  A reference to self so this method may be "chained".

## ◆ set_timestamp()

embed & dpp::embed::set_timestamp | ( | time_t | tstamp | ) |

Set embed timestamp.

Parameters

  tstamp | The timestamp to show in the footer, should be in UTC

Returns
  A reference to self so this method may be "chained".

## ◆ set_title()

embed & dpp::embed::set_title | ( | std::string_view | text | ) |

Set embed title.

Parameters

  text | The text of the title. It will be truncated to the maximum length of 256 UTF-8 characters.

Returns
  A reference to self so this method may be "chained".

## ◆ set_url()

embed & dpp::embed::set_url | ( | std::string_view | url | ) |

Set embed url.

Parameters

  url | the url of the embed

Returns
  A reference to self so this method may be "chained".

## ◆ set_video()

embed & dpp::embed::set_video | ( | std::string_view | url | ) |

Set embed video.

Parameters

  url | The embed video url

Returns
  A reference to self so this method may be "chained".

## Member Data Documentation

## ◆ author

std::optional<embed_author> dpp::embed::author

Optional: Author information.

## ◆ color

std::optional<uint32_t> dpp::embed::color

Optional: Color code of the embed.

## ◆ description

std::string dpp::embed::description

Optional: Description of embed.

## ◆ fields

std::vector<embed_field> dpp::embed::fields

Optional: Fields information.

## ◆ footer

std::optional<embed_footer> dpp::embed::footer

Optional: Footer information.

## ◆ image

std::optional<embed_image> dpp::embed::image

Optional: Image information.

## ◆ provider

std::optional<embed_provider> dpp::embed::provider

Optional: Provider information.

Warning
  Can't send this.

## ◆ thumbnail

std::optional<embed_image> dpp::embed::thumbnail

Optional: Thumbnail information.

## ◆ timestamp

time_t dpp::embed::timestamp

Optional: Timestamp of embed content.

## ◆ title

std::string dpp::embed::title

Optional: Title of embed.

## ◆ type

std::string dpp::embed::type

Optional: Type of embed.

Note
  Always "rich" for webhook embeds.

## ◆ url

std::string dpp::embed::url

Optional: URL of embed.

## ◆ video

std::optional<embed_image> dpp::embed::video

Optional: Video information.

Warning
  Can't send this.

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