D++ (DPP)
C++ Discord API Bot Library
Loading...
Searching...
No Matches
Using D++ with C++ modules

D++ is offered as a C++ module, which offers improved compile times over a traditional header.

In order to enable support, you must use C++20 (or later) with any module-supporting compiler. To activate the feature, pass the DPP_MODULES flag to CMake. Ensure that the generated build system supports modules (for CMake, this is usually Ninja; note CMake does not currently support modules with Makefile).

Once this is done, simply import dpp; and we're good to go!

#include <string>
#include <typeinfo>
import dpp;
int main() {
dpp::cluster bot("YOUR_BOT_TOKEN_HERE");
bot.on_slashcommand([](const dpp::slashcommand_t& event) -> void {
if (event.command.get_command_name() == "ping") {
event.reply("Pong!");
}
});
bot.on_ready([&bot](const dpp::ready_t& event) -> void {
bot.global_command_create(
dpp::slashcommand("ping", "Ping pong!", bot.me.id)
);
}
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition cluster.h:89
std::string get_command_name() const
Get the command name for a command interaction.
Represents an application command, created by your bot either globally, or on a guild.
Definition appcommand.h:1436
auto run_once()
Run some code within an if() statement only once.
Definition once.h:41
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition cluster.h:72
interaction command
command interaction
Definition dispatcher.h:789
Session ready.
Definition dispatcher.h:1072
User has issued a slash command.
Definition dispatcher.h:806
D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0