The source code for a Discord bot built on Python and run on Docker, that I am creating to learn more about the
discord.py rewrite, as well as an excuse to do something when I'm
bored.
I'm mainly using the discord.py library, and experimenting with PyNaCl for voice support.
As of right now, I do not plan on making my bot for public use, so I will not be providing a link to invite the bot to servers. However, this may change later on.
If you would like to see more projects from me, make sure to check out my GitHub!
The bot's documentation can be found here.
I have already created a Dockerfile
that can be
used to build the Docker container which will run the bot. It does the following:
- Pulls the Python 3 Base Image from the Docker Repository.
- Sets the working directory to
/usr/src/app
. - Copies all the program files to the working directory.
- Installs all the package dependencies required for the project
(See
requirements.txt
) - The
CMD
andENTRYPOINT
instructions tell the container to run the bot (launcher.py
) when the container starts.
First check if docker is installed with docker --version
(docker-compose --version
or docker ps
might be needed
instead.) In case Docker is not installed, install it with this guide. Once
it is installed, you can use the
docker_setup.sh
or
docker_setup.bat
scripts that I have
created to automatically build the image, create a thonk-bot
container, and run container.
- Python 3.9.0+ (3.8.5+ may work but is not recommended)
- All packages listed in
requirements.txt
- Docker/Docker.io (Optional, used for running with docker)
All private bot & API info are stored in an Environment file (.env
). Create it in thonk-bot/lib/bot/.env
and make
sure that the following are available in the file:
- Token
- Prefix
- Brainshop API (API KEY)
- Brainshop API (BRAIN ID)
If you're unsure of what to do, just paste the following into the file (make sure to replace the placeholders with the proper information!):
TOKEN="<TOKEN GOES HERE>"
PREFIX="<PREFIX GOES HERE>"
API_KEY="<BRAINSHOP API KEY GOES HERE>"
BRAIN_ID="<BRAINSHOP BRAIN ID GOES HERE>"
The TOKEN
is the bot key that you generate from your application in the Discord Developer page. This bot will also
contain code for slash-commands, so you will need to make sure your bot app has access to them.
If you plan on using part of or even all of this code for your own bots, you are welcome to do so and modify it as well.
However, I ask that you credit me and keep the LICENSE
file intact to comply with the
GNU GPL v3 license. It may seem annoying, but it helps
ensure that the work I put into this does not go to waste. Thank you for understanding!