| 1 | #include <dpp/dpp.h> |
| 2 | |
| 3 | int main() { |
| 4 | dpp::cluster bot("token"); |
| 5 | |
| 6 | bot.on_log(dpp::utility::cout_logger()); |
| 7 | |
| 8 | /* The event is fired when someone issues your commands */ |
| 9 | bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) { |
| 10 | /* Check which command they ran */ |
| 11 | if (event.command.get_command_name() == "thinking") { |
| 12 | /* |
| 13 | * true for Ephemeral. |
| 14 | * You can set this to false if you want everyone to see the thinking response. |
| 15 | */ |
| 16 | event.thinking(true, [event](const dpp::confirmation_callback_t& callback) { |
| 17 | event.edit_original_response(dpp::message("thonk")); |
| 18 | }); |
| 19 | |
| 20 | } |
| 21 | }); |
| 22 | |
| 23 | bot.on_ready([&bot](const dpp::ready_t& event) { |
| 24 | if (dpp::run_once<struct register_bot_commands>()) { |
| 25 | /* Create a new global command on ready event */ |
| 26 | dpp::slashcommand newcommand("thinking", "Thinking example...", bot.me.id); |
| 27 | |
| 28 | /* Register the command */ |
| 29 | bot.global_command_create(newcommand); |
| 30 | } |
| 31 | }); |
| 32 | |
| 33 | bot.start(dpp::st_wait); |
| 34 | |
| 35 | return 0; |
| 36 | } |
nothing calls this directly
no test coverage detected