Templated Setup
Install Prerequisites
Install Git
- If you want to use Git in the command line, run
sudo apt install git
on Ubuntu, on Windows you can download Git for Windows or usechoco install git
if you have Chocolatey installed. - If you're less terminal-inclined, you can install a Git GUI wrapper. There's a nice list here.
- I would personally recommend GitKraken. The free version has everyhting you need, (although their conflict resolver for Pro is nice,) and you can also get Pro free with GitHub Education!
ANDInstall CMake
- Debian-based (Ubuntu) run
sudo apt install cmake
- Fedora/RHEL-based
sudo dnf install cmake
- Windows Download CMake or run
choco install cmake
if you have Chocolatey installed.
AND Install C++
- Install a C++ compiler
- the typical standard on Linux is
gcc
, you can install it on Ubuntu withsudo apt install gcc
clang
is an alternative that I feel has better error statements, you can install it on Ubuntu withsudo apt install clang
- The typical compiler on Windows is Microsoft Visual C++
- MinGW or Cygwin are valid alternatives if you like GCC running on Windows, there's also WSL which allows you to run a Linux based distribution under Windows.
- the typical standard on Linux is
AND OPTIONALLYInstall vcpkg
- Vcpkg is a cross platform library manager, you can install it by reading the instructions on this page
- This program is required for building Echo under Windows.
AND Install Libraries
Note: Discord++ requires a minimum of Boost 1.71. If you're using an older distro your package repositories may have an older version.
- Debian-based (Ubuntu)
sudo apt install build-essential libssl-dev
and optionallylibboost-all-dev
- Fedora/RHEL-based
sudo dnf install openssl-devel
and optionallyboost-devel
- Vcpkg
vcpkg install boost-system openssl
and optionallyboost-beast
OR Install Everything at Once
- Debian-based (Ubuntu)
sudo apt install git clang cmake build-essential libssl-dev
and optionallylibboost-all-dev
Set Up Your Repository
Optionally Use a template
- Click the 'Use this template' button in the upper-right of the Echo or Build-A-Bot page right above the number of commits
- Follow the steps GitHub gives you
Clone the Code
Run git clone --recursive https://github.com/USERNAME/REPONAME.git
in your desired directory with your username and repository name.
If you used Build-A-Bot as you can now run build-a-bot.sh
Register a Bot
- Go to Discord's Developer Portal 'Application' page, it will prompt you to sign in By the way, do you have 2FA enabled? It's a really good idea, especially with bots on your account
- Click 'New Application', and enter a name for your bot
- Click on 'Bot' under 'Settings' on the right, click 'Add Bot', and then 'Yes, do it!'
- Make note of the 'Copy' button under 'Token', we'll get back to this later
- Also, come back and click the 'regenerate' button if anyone ever gets a hold of your bot's token
- If you want to give your bot an avatar, I'd recommend doing it both on the 'General Information' landing page and here on the 'Bot' page, it makes things less confusing if you ever need to come back.
Add your Bot to a Server
- Copy
https://discordapp.com/api/oauth2/authorize?client_id=[ID]&scope=bot&permissions=[permissions]
to somewhere, such as notepad - Go back to the 'General Information' page of your application
- Click 'Copy' under 'Client ID', and paste it into your URL, taking care to replace the word and brackets
- Go to the 'Bot' page
- Select the permissions you want your bot to have from under 'Bot Permissions'
- You probably want at least 'Send Messages',
2048
- You probably want at least 'Send Messages',
- Click the 'Copy' button under 'Permissions Integer', and paste it in your URL, make sure you get the brackets like before
- Paste the URL into a web btowser, select a server to add it to, and click 'Authorize'
Build your Bot
- Create a
build
directory (folder) withmkdir build
- Enter the folder with
cd build
- Go back to your Application's 'bot' page from before, and copy the token. Run
echo Bot [token] > token.dat
, replacing[token]
with your bot's token. Alternatively, you can set theECHO_BOT_TOKEN
environment variable toBot [token]
. - Build the makefiles with
cmake ../
- If you are using vcpkg then run
cmake -DCMAKE_TOOLCHAIN_FILE="your vcpkg.cmake folder" ../
- If you are using vcpkg then run
- Build the bot with
make
(if you are using Visual Studio openecho_bot.sln
and build from there) - Run the bot with
./echo_bot
- You can change the executable name by modifying the
project
command inCMakeLists.txt
- You can change the executable name by modifying the
- ???
- Profit! If you used Echo as a template mention your bot in a scope it can read & write in: it should echo back your message.