Debian Codegraph @

docpages/example_code/webhooks.cpp

raw symbols SCIP
1 #include <dpp/dpp.h>
2 #include <chrono>
3 #include <thread>
4
5 int main()
6 {
7 /* If you just want to fire webhooks, you can instantiate a cluster with no token */
8 dpp::cluster bot;
9
10 /* Start the cluster in its own thread */
11 bot.start(dpp::st_return);
12
13 /* Construct a webhook object using the URL you got from Discord */
14 dpp::webhook wh("https://discord.com/api/webhooks/833047646548133537/ntCHEYYIoHSLy_GOxPx6pmM0sUoLbP101ct-WI6F-S4beAV2vaIcl_Id5loAMyQwxqhE");
15
16 /* Send a message with this webhook asynchronously */
17 bot.execute_webhook(wh, dpp::message("Have a great time here :smile:"));
18
19 /* Wait here for the webhook to complete, but we could do anything we need here */
20 while (bot.active_requests() > 0) {
21 std::this_thread::sleep_for(std::chrono::seconds(1));
22 }
23
24 /* When we return here, the cluster will be terminated */
25 return 0;
26 }