D++ (DPP)  10.0.30
C++ Discord API Bot Library
Webhooks

Webhooks are a simple way to post messages from other apps and websites into Discord. They allow getting automated messages and data updates sent to a text channel in your server. Read more in this article about Webhooks.

The following code shows how to send messages in a channel using a webhook.

#include <dpp/dpp.h>
int main()
{
dpp::cluster bot(""); /* Normally, you put your bot token in here, but its not required for webhooks. */
/* Construct a webhook object using the URL you got from Discord */
dpp::webhook wh("https://discord.com/api/webhooks/833047646548133537/ntCHEYYIoHSLy_GOxPx6pmM0sUoLbP101ct-WI6F-S4beAV2vaIcl_Id5loAMyQwxqhE");
/* Send a message with this webhook */
bot.execute_webhook_sync(wh, dpp::message("Have a great time here :smile:"));
return 0;
}

The above is just a very simple example. You can also send embed messages. All you have to do is to add an embed to the message you want to send. If you want to, you can also send it into a thread.

dpp.h
main
int main()
Definition: soak.cpp:28
dpp::message
Represents messages sent and received on Discord.
Definition: message.h:2007
dpp::utility::cout_logger
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout.
Definition: dispatcher.h:228
dpp::webhook
Represents a discord webhook.
Definition: webhook.h:79
dpp::cluster
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:99