Blockbot is a Discord bot, written in Python, that is maintained by the Redbrick Webgroup. This project uses hikari
, an opinionated microframework, to interface with the Discord API. hikari-arc
is the command handler of choice.
bot.py
- This is the file that contains the bot configuration and instantiation, while also being responsible for loading the bot extensions.
extensions/
- This directory is home to the custom extensions (known as cogs in
discord.py
, or command groups) that are loaded when the bot is started. Extensions are classes that encapsulate command logic and can be dynamically loaded/unloaded. Inhikari-arc
, an intuitive plugin system is used.
- This directory is home to the custom extensions (known as cogs in
config.py
- Configuration secrets and important constants (such as identifiers) are stored here. The secrets are loaded from environment variables, so you can set them in your shell or in a
.env
file.
- Configuration secrets and important constants (such as identifiers) are stored here. The secrets are loaded from environment variables, so you can set them in your shell or in a
utils.py
- Simple utility functions are stored here, that can be reused across the codebase.
As a prerequisite, you need to have a bot application registered on the Discord developer portal.
- Create a Discord bot application here.
- When you have a bot application, register it for slash commands:
- Go to "OAuth2 > URL Generator" on the left sidebar, select the
bot
andapplications.commands
scopes, scroll down & select the bot permissions you need (for development, you can selectAdministator
). - Copy and visit the generated URL at the bottom of the page to invite it to the desired server.
- Go to the Discord developer portal and under "Bot" on the left sidebar, click
Reset Token
. Copy the generated token.
git clone
andcd
into this repository.- It's generally advised to work in a Python virtual environment:
python3 -m venv .venv
source .venv/bin/activate
- Create a new file called
.env
inside the repo folder and paste your bot token into the file as such:
TOKEN=<Discord bot token here>
- Run
pip install -r requirements.txt
to install the required packages. - Once that's done, start the bot by running
python3 -m src
.
- If you get errors related to missing token environment variables, run
source .env
.