From d664f68f47694b5dfd1419cab6df2a16f65e8cde Mon Sep 17 00:00:00 2001 From: kaedeek Date: Mon, 13 Apr 2026 18:30:42 +0900 Subject: [PATCH] feat(example): Add minimal slash command (ping) example. --- example/simple_example.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 example/simple_example.cpp diff --git a/example/simple_example.cpp b/example/simple_example.cpp new file mode 100644 index 0000000000..3e6e2935c9 --- /dev/null +++ b/example/simple_example.cpp @@ -0,0 +1,23 @@ +#include +#include + +int main() { + dpp::cluster bot(std::getenv("BOT_TOKEN")); + + bot.on_slashcommand([](auto event) { + if (event.command.get_command_name() == "ping") { + event.reply("Pong!"); + } + }); + + bot.on_ready([&bot](auto event) { + if (dpp::run_once()) { + bot.global_command_create( + dpp::slashcommand("ping", "Ping pong!", bot.me.id) + ); + } + }); + + bot.start(dpp::st_wait); + return 0; +} \ No newline at end of file