A Discord.py bot, utilizing docker.
Commands and paths in this repo will be in Unix format.
To run this bot, first install Docker. Then:
- Copy the example env file
cd src/ && cp .env.EXAMPLE .env - Replace "YOUR_DISCORD_BOT_TOKEN_HERE" with your Discord Bot token and MASTER_GUILD with the ID of the main guild that your bot will be active in.
docker compose up -d- The bot should come online. You can use the
>hccommand to run a healthcheck on the system.
If you already have postgres installed on your system then you may have conflicting ports, in that case change the POSTGRES_PORT to a free port in the .env, usually 5433. Then rebuild by using following command:
docker compose up -d --build
- Currently using Postgres 17.5
- The default port is defined in your
.envThe Postgres db will create a folder called postgres data at/src/db/postgres-data/Do not delete this folder if you want the data in it to persist!
Otherwise, to reset the db run sudo rm -r /src/db/postgres-db/
The init script at/src/db/init.sql runs on the initial startup
The flask API is located at /src/api/
It should run on http://127.0.0.1:5000 unless you've tampered with the .env settings for flask.
The functions that connect the API to the database are at /src/api/core/db_helper.py and serve as an abstraction over the psycopg functions.
A .postman directory is included, which contains a postman collection if you feel like messing about with the API locally in postman.
The Bot is running using Discord.py, and cogged commands.
- While not recommended, you may also run the bot manually for debugging using
python main.pyif your Token is in the .env, however many features of the bot will not work. - TODO: make the bot start independent of other infrastructure.
cogs are located at
/src/bot/cogs/*/, and are seperated by their purpose.
The functions that connect the bot to the API are at /src/bot/core/api_helper.py and serve as an abstraction over the requests happening in the background.
There is also a /src/bot/core/embeds.py, however I might choose to depricate that in the future.
- Description: Synchronizes all guild members with the points database. Members who are already present in the database are skipped.
- Arguments: None.
- Usage:
>sync_users - Output: An embedded message showing how many users were added to the points table.
- Description: Retrieves and displays the points of a specific guild member.
- Arguments:
user: A mention or reference to a Discord member.
- Usage:
>get_points @user - Output: An embedded message displaying the mentioned user's current points.
- Description: Updates the points of a specific user by adding or subtracting a specified amount.
- Arguments:
user: A mention or reference to a Discord user.amount: The number of points to add (positive) or subtract (negative).
- Usage:
- To add points:
>update_points @user 100 - To remove points:
>update_points @user -50
- To add points:
- Output: An embedded message confirming the amount of points added or removed from the user.
- Description: Fetches and displays the top 10 users with the most points in the guild.
- Arguments: None.
- Usage:
>top_10 - Output: An embedded message showing the top 10 users and their respective points.
- Description: Fetches and displays the current settings for the guild
- Arguments: None.
- Usage:
>settings - Output: An embedded message showing the guild settings
- Description: An interactive menu that allows a user to change guild settings
- Arguments: None.
- Usage:
>update_settings - Output: An embedded message that first asks what kind of settings you wish to change, and then another based on what you select.