Python Discord Bot - Implemented with discord.py
The bot itself only has the basics needed to connect to discord and run. Functionality can be provided via extensions, such as the ones provided in discord-bot-extensions
bot.py
[--config] Path to config.yml
[--data] Path to writable data directory for storage
On the initial run, the app will create and save a config.yml. See data/config.yml for an example.
Secrets should be stored in local files. The files should be named corresponding to the key specified in the code. In the core app, there's only one key discord_api_token
. The app will automatically check for secrets in the following paths:
- /run/secrets
- /var/run/secrets
You can also specify a path to a secret file by setting an enviroment variable with the key name appended with _FILE
, as in DISCORD_API_TOKEN_FILE
.
$ git clone https://github.com/nalabelle/discord-bot.git
$ pip install -r discord-bot/requirements.txt
$ DISCORD_API_TOKEN_FILE=/path/to/token ./discord-bot/bot.py
secrets:
discord_api_token: /path/to/token
services:
discord-bot:
image: nalabelle/discord-bot
secrets:
- discord_api_token
volumes:
- discord-bot:/app/data
$ git clone https://github.com/nalabelle/discord-bot.git
$ docker build -t discord-bot:latest discord-bot
$ docker run \
-v /path/to/token:/run/secrets/discord_api_token:ro
--rm -it discord-bot
I checked out discord-bot-extensions into
data/extensions
, and then I let the extensions manage my config as follows
command_prefix: '!'
discord_log_level: ERROR
extension_filters:
- .git
extensions:
- data.extensions._dependencies
- data.extensions.admin_config
- data.extensions.admin_extension
- data.extensions.status
- data.extensions.weather
log_level: debug
Extensions for https://github.com/nalabelle/discord-bot
Clone this repo into your discord-bot /data/extensions
path, then load the basic extensions into config:
extensions:
- data.extensions._dependencies
- data.extensions.admin_extension