A Discord API written in C++.
Links:
- Boost
Required by what are currently the only modules: - OpenSSL
- Crypto++
- Websocket++
Install everything (Debian-based distros):
sudo apt install build-essential libboost-all-dev libssl-dev libcrypto++-dev libcurl4-openssl-dev libwebsocketpp-dev libcurlpp-dev
Install everything (Fedora/RHEL-based distros):
sudo dnf install openssl-devel boost-devel cryptopp-devel cryptopp curlpp-devel websocketpp-devel cmake
- nlohmann::json
Included by what are currently the only modules: - cURLpp
-
Download:
- Download or
git clone
Discord++, a Discord++ REST module, and a Discord++ Websocket module. - Place them all in a subdirectory of your project.
- Download or
-
In CMake:
-
Add
ADD_SUBDIRECTORY(<relative path>)
for Discord++ and each module.add_subdirectory(lib/discordpp) add_subdirectory(lib/rest-curlpp) add_subdirectory(lib/websocket-websocketpp)
-
Add
discordpp
and each module to yourINCLUDE_DIRECTORIES
command.INCLUDE_DIRECTORIES( ${discordpp_SOURCE_DIR} ${discordpp-rest-curlpp_SOURCE_DIR} ${discordpp-websocket-websocketpp_SOURCE_DIR})
-
-
In your code:
-
Include
discordpp/bot.hh
and the header file from each submodule.Example:
#include <discordpp/bot.hh> #include <discordpp/rest-curlpp.hh> #include <discordpp/websocket-websocketpp.hh>
-
Create a Bot object, and pass it your token, a REST module, and a Websocket module.
discordpp::Bot bot(token, std::make_shared<discordpp::RestCurlPPModule>(),std::make_shared<discordpp::WebsocketWebsocketPPModule>());
-
Add responses to events with the Bot's
bot.addHandler("MESSAGE_CREATE", [](discordpp::Bot* bot, aios_ptr asio_ios, json msg){ //Do Stuff });
-
Create an
boost::asio::io_service
-
Initialize the bot object with its
init(std::shared_pointer<boost::asio::io_service> asio_ios)
. -
Run the
boost::asio::io_service
-