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>
#include <chrono>
#include <thread>
int main()
{
dpp::webhook wh(
"https://discord.com/api/webhooks/833047646548133537/ntCHEYYIoHSLy_GOxPx6pmM0sUoLbP101ct-WI6F-S4beAV2vaIcl_Id5loAMyQwxqhE");
std::this_thread::sleep_for(std::chrono::seconds(1));
}
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:89
void execute_webhook(const class webhook &wh, const struct message &m, bool wait=false, snowflake thread_id=0, const std::string &thread_name="", command_completion_event_t callback=utility::log_error())
Execute webhook.
void start(start_type return_after=st_wait)
Start the cluster, connecting all its shards.
size_t active_requests()
Get the number of currently active HTTP(S) requests active in the cluster. This total includes all in...
Represents a discord webhook.
Definition: webhook.h:59
@ st_return
Return immediately after starting shard threads. If you set the parameter of cluster::start() to this...
Definition: cluster.h:82
Represents messages sent and received on Discord.
Definition: message.h:2071
- Note
- For just sending a webhook, the example above is overkill. If you are here because you searched for 'how to send a Discord webhook in C++', you'll quickly learn that D++ can do much more than just send webhooks! 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. For further examples, check the rest of the site.