Skip to content

luccanunes/discord.cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Discord API wrapper for creating C++ BOT's


Features

  • Command class!!

About

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.

Example

#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;
}

Installation and set up

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.

Create your solution

Add a source file and paste the example code

Add the compiler include path:

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:

  1. Right click your project name and select properties
  2. Select "C/C++"
  3. Click "Additional Include Directories", selected the small arrow on the right and click "Edit"
  4. Click the new folder icon and then the three dots to starting browsing your file explorer.
  5. Select the "/src" folder in the directory that you installed discord.cpp
  6. Click "Ok" and "Apply".

Add the linker path:

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:

  1. Follow step 1 of "Add the compiler include path"
  2. Select "Linker"
  3. Click "Additional Library Directories", selected the small arrow on the right and click "Edit"
  4. Click the new folder icon and then the three dots to starting browsing your file explorer.
  5. Select the "/src/Release" folder in the directory that you installed discord.cpp
  6. Click "Ok" and "Apply".
  7. Now, go to the "Input" tab, still in the linker properties
  8. Select "Additional Dependencies", and edit the text string by adding "discord-cpp.lib;" to its beginning
  9. Hit "Apply" and "Ok" and you should be good to go.

Having trouble?

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.

Create your solution

Add a source file and paste the example code

Add the compiler include path:

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:

  1. Right click your project name and select properties
  2. Select "C/C++"
  3. Click "Additional Include Directories", selected the small arrow on the right and click "Edit"
  4. Click the new folder icon and then the three dots to starting browsing your file explorer.
  5. Select the "/src" folder in the directory that you installed discord.cpp
  6. Click "Ok" and "Apply", you should be good to go!

Having trouble?

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

Documentation

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

Maintaining discord.cpp is only possible thanks to these incredible and easy to use libraries.

Contributing

discord.cpp is really just a small project right now, so, if you feel like it, please consider helping us out!

About

A Discord API wrapper for creating BOT's

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •