Debian Codegraph @

docpages/example_code/embeds.cpp

raw symbols SCIP
1 #include <dpp/dpp.h>
2
3 int main() {
4 /* Setup the bot */
5 dpp::cluster bot("token");
6
7 bot.on_log(dpp::utility::cout_logger());
8
9 /* The event is fired when someone issues your commands */
10 bot.on_slashcommand([](const dpp::slashcommand_t& event) {
11 /* Check which command they ran */
12 if (event.command.get_command_name() == "embed") {
13 /* Create an embed */
14 dpp::embed embed = dpp::embed()
15 .set_color(dpp::colors::sti_blue)
16 .set_title("Some name")
17 .set_url("https://dpp.dev/")
18 .set_author("Some name", "https://dpp.dev/", "https://dpp.dev/DPP-Logo.png")
19 .set_description("Some description here")
20 .set_thumbnail("https://dpp.dev/DPP-Logo.png")
21 .add_field(
22 "Regular field title",
23 "Some value here"
24 )
25 .add_field(
26 "Inline field title",
27 "Some value here",
28 true
29 )
30 .add_field(
31 "Inline field title",
32 "Some value here",
33 true
34 )
35 .set_image("https://dpp.dev/DPP-Logo.png")
36 .set_footer(
37 dpp::embed_footer()
38 .set_text("Some footer text here")
39 .set_icon("https://dpp.dev/DPP-Logo.png")
40 )
41 .set_timestamp(time(0));
42
43 /* Create a message with the content as our new embed. */
44 dpp::message msg(event.command.channel_id, embed);
45
46 /* Reply to the user with the message, containing our embed. */
47 event.reply(msg);
48 }
49 });
50
51 bot.on_ready([&bot](const dpp::ready_t& event) {
52 if (dpp::run_once<struct register_bot_commands>()) {
53 /* Create and register a command when the bot is ready */
54 bot.global_command_create(dpp::slashcommand("embed", "Send a test embed!", bot.me.id));
55 }
56 });
57
58 bot.start(dpp::st_wait);
59
60 return 0;
61 }