This example demonstrates adding multiple buttons, receiving button clicks, and sending response messages.
#include <dpp/dpp.h>
int main() {
dpp::message msg(event.command.channel_id, "What is 5+5?");
msg.add_component(
dpp::component().add_component(
dpp::component()
.set_label("9")
.set_style(dpp::cos_primary)
.set_id("9")
)
.add_component(
dpp::component()
.set_label("10")
.set_style(dpp::cos_primary)
.set_id("10")
)
.add_component(
dpp::component()
.set_label("11")
.set_style(dpp::cos_primary)
.set_id("11")
)
);
event.reply(msg);
}
});
event.reply(dpp::message("You got it right!").set_flags(dpp::m_ephemeral));
} else {
event.reply(dpp::message("Wrong! Try again.").set_flags(dpp::m_ephemeral));
}
});
if (dpp::run_once<struct register_bot_commands>()) {
bot.global_command_create(
dpp::slashcommand(
"math",
"A quick maths question!", 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:89
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:1397
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:72
interaction command
command interaction
Definition: dispatcher.h:688
Session ready.
Definition: dispatcher.h:971
User has issued a slash command.
Definition: dispatcher.h:705
This code will send a different message for correct and incorrect answers.