#include #include /* Be sure to place your token in the line below. * Follow steps here to get a token: * https://dpp.dev/creating-a-bot-application.html * When you invite the bot, be sure to invite it with the * scopes 'bot' and 'applications.commands', e.g. * https://discord.com/oauth2/authorize?client_id=940762342495518720&scope=bot+applications.commands&permissions=139586816064 */ const std::string BOT_TOKEN = "add your token here"; int main() { /* Create bot cluster */ dpp::cluster bot(BOT_TOKEN); /* Output simple log messages to stdout */ bot.on_log(dpp::utility::cout_logger()); /* Handle slash command with the most recent addition to D++ features, coroutines! */ bot.on_slashcommand([](const dpp::slashcommand_t& event) -> dpp::task { if (event.command.get_command_name() == "ping") { co_await event.co_reply("Pong!"); } co_return; }); /* Register slash command here in on_ready */ bot.on_ready([&bot](const dpp::ready_t& event) { /* Wrap command registration in run_once to make sure it doesnt run on every full reconnection */ if (dpp::run_once()) { bot.global_command_create(dpp::slashcommand("ping", "Ping pong!", bot.me.id)); } }); /* Start the bot */ bot.start(dpp::st_wait); return 0; }