| 1 | #include <dpp/dpp.h> |
| 2 | |
| 3 | const std::string BOT_TOKEN = "add your token here"; |
| 4 | |
| 5 | int main() { |
| 6 | dpp::cluster bot(BOT_TOKEN); |
| 7 | |
| 8 | bot.on_log(dpp::utility::cout_logger()); |
| 9 | |
| 10 | bot.on_slashcommand([](const dpp::slashcommand_t& event) { |
| 11 | if (event.command.get_command_name() == "ping") { |
| 12 | event.reply("Pong!"); |
| 13 | } |
| 14 | }); |
| 15 | |
| 16 | bot.on_ready([&bot](const dpp::ready_t& event) { |
| 17 | if (dpp::run_once<struct register_bot_commands>()) { |
| 18 | bot.global_command_create(dpp::slashcommand("ping", "Ping pong!", bot.me.id)); |
| 19 | } |
| 20 | }); |
| 21 | |
| 22 | bot.start(dpp::st_wait); |
| 23 | } |