Debian Codegraph @

docpages/example_code/ephemeral.cpp

raw symbols SCIP
1 #include <dpp/dpp.h>
2
3 int main() {
4 /* Create 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() == "hello") {
13 /* Reply to the user, but only let them see the response. */
14 event.reply(dpp::message("Hello! How are you today?").set_flags(dpp::m_ephemeral));
15 }
16 });
17
18 bot.on_ready([&bot](const dpp::ready_t& event) {
19 if (dpp::run_once<struct register_bot_commands>()) {
20 /* Create and Register the command */
21 bot.global_command_create(dpp::slashcommand("hello", "Hello there!", bot.me.id));
22 }
23 });
24
25 bot.start(dpp::st_wait);
26
27 return 0;
28 }