D++ (DPP)
C++ Discord API Bot Library
Building a Discord Bot using CLion & VCPKG (Windows)
Warning
This page is for Windows only. If you want to use CLion on Linux, look to use this page. Like always with windows, we highly recommends you use the pre-made Visual Studio template. This tutorial also assumes you have installed D++ via VCPKG already. If you haven't, look at this page.

Changing Toolchains

Note
If you have already configured your toolchain to use anything but MinGW64, then you can skip to the next section. Otherwise, it is critical that you follow along with this section. It should also be noted that you need Visual Studio for this.

Head on over to File > Settings (Ctrl+Alt+S), then navigate to Build, Execution, Deployment > Toolchains.

If there is a Visual Studio toolchain there, drag it to the top of the list. This will make the Visual Studio toolchain the default toolchain.

If you don't have the Visual Studio toolchain, you can hit the plus symbol above the list of toolchains and add a toolchain. This is also how you can add WSL as a toolchain!

From there, you need to drag it to the top (if it didn't already add at the top) to ensure it's the default toolchain.

Using VCPKG with CLion

To use vcpkg in CLion, add the following line to your CMake options in the settings (Located under Settings > Build, Execution, Deployment > CMake)

-DCMAKE_TOOLCHAIN_FILE=path_to_vcpkg_root_folder/scripts/buildsystems/vcpkg.cmake

For example, if your root folder is C:/vcpkg/ then the CMake option will be:

-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake

Making a test application.

Open your main.cpp file and then copy and paste the following example program in. Then, set your bot token (see Creating a Bot Token). Here's how your main.cpp file should look:

#include <dpp/dpp.h>
const std::string BOT_TOKEN = "add your token here";
int main() {
dpp::cluster bot(BOT_TOKEN);
bot.on_slashcommand([](const dpp::slashcommand_t& event) {
if (event.command.get_command_name() == "ping") {
event.reply("Pong!");
}
});
bot.on_ready([&bot](const dpp::ready_t& event) {
if (dpp::run_once<struct register_bot_commands>()) {
bot.global_command_create(dpp::slashcommand("ping", "Ping pong!", bot.me.id));
}
});
bot.start(dpp::st_wait);
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:80
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:1342
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:63
interaction command
command interaction
Definition: dispatcher.h:678
Session ready.
Definition: dispatcher.h:961
User has issued a slash command.
Definition: dispatcher.h:695

If everything went well, you should now have a functioning bot! If not, feel free to ask us on the D++ discord server.

Troubleshooting

If you see a message like Detecting C compiler ABI info - failed or something along the lines of "cl.exe" is not able to compile a simple test program, then try to reinstall Windows Build Tools along with the Windows SDK from the Visual Studio Installer.

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ 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