If you've been in a server and used a bot or even seen a message from a bot, you might have seen a special message type, often sent by these bots. These are called embeds! In this section, we will show how to create an embed and reply to a user, using our newly created embed!
#include <dpp/dpp.h>
int main() {
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));
dpp::message msg(event.command.channel_id, embed);
event.reply(msg);
}
});
if (dpp::run_once<struct register_bot_commands>()) {
bot.global_command_create(
dpp::slashcommand(
"embed",
"Send a test embed!", bot.me.id));
}
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:82
std::string get_command_name() const
Get the command name for a command interaction.
Represents an application command, created by your bot either globally, or on a guild.
Definition: appcommand.h:999
@ i_message_content
Intent for receipt of message content.
Definition: intents.h:65
@ i_default_intents
Default D++ intents (all non-privileged intents)
Definition: intents.h:73
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:65
interaction command
command interaction
Definition: dispatcher.h:585
Session ready.
Definition: dispatcher.h:877
User has issued a slash command.
Definition: dispatcher.h:607
The code will send the following message.