D++ (DPP)
C++ Discord API Bot Library
Sending Embeds

You might have seen these special messages, often sent by bots. In this section, we will show how to create an embed.

Note
Because this example utilizes message content, it requires the message content privileged intent.
#include <dpp/dpp.h>
int main() {
/* Setup the bot */
/* Message handler to look for a command called !embed */
bot.on_message_create([&bot](const dpp::message_create_t & event) {
if (event.msg.content == "!embed") {
/* create the embed */
dpp::embed embed = dpp::embed().
set_color(dpp::colors::sti_blue).
set_title("Some name").
set_url("https://dpp.dev/").
set_author("Some name", "https://dpp.dev/", "https://dpp.dev/DPP-Logo.png").
set_description("Some description here").
set_thumbnail("https://dpp.dev/DPP-Logo.png").
add_field(
"Regular field title",
"Some value here"
).
add_field(
"Inline field title",
"Some value here",
true
).
add_field(
"Inline field title",
"Some value here",
true
).
set_image("https://dpp.dev/DPP-Logo.png").
set_footer(dpp::embed_footer().set_text("Some footer text here").set_icon("https://dpp.dev/DPP-Logo.png")).
set_timestamp(time(0));
/* reply with the created embed */
bot.message_create(dpp::message(event.msg.channel_id, embed).set_reference(event.msg.id));
}
});
bot.start(dpp::st_wait);
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:271
@ i_message_content
Intent for receipt of message content.
Definition: intents.h:64
@ i_default_intents
Default D++ intents (all non-privileged intents)
Definition: intents.h:72
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:254
Create message.
Definition: dispatcher.h:1354
message msg
message that was created (sent).
Definition: dispatcher.h:1363
std::string content
Definition: message.h:1115

The code will send the following message.

D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ 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