https://github.com/brainboxdotcc/command_example
An example of splitting slash commands into separate files using D++
https://github.com/brainboxdotcc/command_example
cpp cpp17 discord discord-api discord-api-v10 discord-api-wrapper discord-bot dpp
Last synced: 8 months ago
JSON representation
An example of splitting slash commands into separate files using D++
- Host: GitHub
- URL: https://github.com/brainboxdotcc/command_example
- Owner: brainboxdotcc
- License: apache-2.0
- Created: 2022-06-10T17:36:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-14T11:50:30.000Z (over 3 years ago)
- Last Synced: 2024-04-25T00:11:08.235Z (over 1 year ago)
- Topics: cpp, cpp17, discord, discord-api, discord-api-v10, discord-api-wrapper, discord-bot, dpp
- Language: C++
- Homepage: https://dpp.dev/
- Size: 23.4 KB
- Stars: 4
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# D++ Multiple Command Example
This is a C++ bot for demonstrating a simple way to have each command in a separate file while using the D++ library.
There are many ways to approach this, and this method is an example of how to do it without having to have a base class and inheritence. All that is needed in each command file is one function which matches a format declares in `command.h`.
Three sample commands are implemented called `ping`, `info` and `help`.
## Compilation
mkdir build
cd build
cmake ..
make -j
If DPP is installed in a different location you can specify the root directory to look in while running cmake
cmake .. -DDPP_ROOT_DIR=
## Running the bot
Create a config.json in the directory above the build directory:
```json
{
"token": "your bot token here",
}
```
Start the bot:
cd build
./command_example
Using the bot:
Type any one of the three example commands to see it running. Note that this bot registers global commands, and uses bulk registration, so any other global commands registered upon this bot token will be **replaced** by the three examples in this program!