- Command class!!
Inspired by the simplicity of discord.py and discord.js, discord.cpp tries to make the process of interacting with the Discord API easier, so you can worry less about all the socket connections under the hood, and focus on making your bot better.
#include <iostream>
#include <dpp.h>
int main()
{
const std::string token = "BOT_TOKEN_HERE";
dpp::Client client;
client.onReady = [&]() {
std::cout << "hello, c++!\n";
std::cout << client.user.id << "\n\n";
};
client.onMessage = [&](const dpp::Message& message) {
if (message.content == "jaaj?") {
message.channel().send("jooj"); // or message.reply("jooj"), which mentions the message author
}
};
client.run(token);
return 0;
}
There are two ways of using discord.cpp. You can use the static library version (with the .lib file), or you can use the header only version.
Static library
First of all, clone the repository to your machine in a directory of your choice (make sure you're cloning the main
branch).
To create your own project using discord.cpp you have to follow these steps, for this example I'll use Visual Studio, but the steps should be the same. Just google the specifics for your IDE of choice.
To starting using discord.cpp and all its features, you first have to tell your IDE/compiler where you're importing it from. Here's how to do it in Visual Studio:
- Right click your project name and select properties
- Select "C/C++"
- Click "Additional Include Directories", selected the small arrow on the right and click "Edit"
- Click the new folder icon and then the three dots to starting browsing your file explorer.
- Select the "/src" folder in the directory that you installed discord.cpp
- Click "Ok" and "Apply".
Now that you've added the include path, the compiler is able to find all the classes and functions declarations, but not really their definitions. For that, we need to include an additional depencie to the linker. Here's how to do it in Visual Studio:
- Follow step 1 of "Add the compiler include path"
- Select "Linker"
- Click "Additional Library Directories", selected the small arrow on the right and click "Edit"
- Click the new folder icon and then the three dots to starting browsing your file explorer.
- Select the "/src/Release" folder in the directory that you installed discord.cpp
- Click "Ok" and "Apply".
- Now, go to the "Input" tab, still in the linker properties
- Select "Additional Dependencies", and edit the text string by adding "discord-cpp.lib;" to its beginning
- Hit "Apply" and "Ok" and you should be good to go.
Please report any bugs or issues you might have! You can do so by creating a issue
Header only
First of all, clone the repository to your machine in a directory of your choice (make sure you're cloning the header-only
branch).
To create your own project using discord.cpp you have to follow these steps. For this example I'll use Visual Studio, but the steps should be the same. Just google the specifics for your IDE of choice.
To starting using discord.cpp and all its features, you first have to tell your IDE/compiler where you're importing it from. Here's how to do it in Visual Studio:
- Right click your project name and select properties
- Select "C/C++"
- Click "Additional Include Directories", selected the small arrow on the right and click "Edit"
- Click the new folder icon and then the three dots to starting browsing your file explorer.
- Select the "/src" folder in the directory that you installed discord.cpp
- Click "Ok" and "Apply", you should be good to go!
Please report any bugs or issues you might have! You can do so by creating a issue
You can also use something like vcpkg to handle all dependencies, those are listed under the Special Thanks section
We're still working on the library documentation, you can follow the updates by checking its github repository or just checking the actual docs website
discord.cpp is really just a small project right now, so, if you feel like it, please consider helping us out!