My friendly little Python Discord Bot
Important
This project is currently a work in progress !
- Table of Contents
- π About
- β¨ Features
- ποΈ Structure
- π¦ Dependencies
- π οΈ Setup
- π Run
- π₯ Inspirations
- π‘ Tips & Tricks
- π License
Ptibot is a lightweight and extensible Discord bot built with Python, designed to help manage simple tasks, send reminders, and moreβall within your Discord server.
Whether you're running a small community or developing a personal assistant, Ptibot provides a clean and developer-friendly starting point.
Project
-
π Reproducibility: The project is built using uv, enabling seamless setup replication across different machines for consistent environments.
-
π Well-Documented: Source files include thorough comments and, where applicable, links and explanations to clarify key settings.
Bot
-
β Reminders: Develop reminder handling (create, delete, etc.) with synchronization support for Google Calendar or other calendar services.
-
π€ ChatBot: Implement a Chat Bot functionality by using the Mistral API under the hood.
-
π οΈ Tools: Develop functionality to manage tasks (create, delete, edit) and group them by category.
-
π° News: Implement a News feed that follows popular RSS feeds, and notify of new posts.
-
β Task Management: Implement functionality to manage tasks (create, delete, mark as completed).
Warning
Following is a list of features I wish to implement, and therefore, are not yet features:
-
πΉ Youtube Tracker: Implement a tracker to alert of new videos choosed youtube channels.
-
π£ Github Tracker: Develop a tracker to alert of events on repositories of connected account.
Note
The project's structure is designed to be self-explanatory, but here are the key components in case you're curious.
Directories
assets
- Contains static image resources used in the project.cogs
- Python modules categorized by functionality.admin.py
- Admin-related commands and logic.common.py
- Shared utility functions or commands.
db
- Contains the application's local database file.ui
- Contains custom UI components
Files
.dockerignore
- Specifies files and directories to exclude from Docker builds..env
- Environment variables for local development (not for production)..env.template
- Template for required environment variables..gitignore
- Specifies files and directories to be ignored by Git..python-version
- Python version specification for tools like pyenv.Dockerfile
- Defines the Docker image build instructions.docker-compose.yml
- Docker Compose configuration file.LICENSE
- Project license.Makefile
- Automation commands for building, testing, and running the app.README.md
- Project documentation and overview.main.py
- Entry point of the application.pyproject.toml
- Python environment and dependency configuration.requirements.txt
- List of Python dependencies.uv.lock
- Lockfile used by uv for reproducible environments.
Note
Here are the main libraries / dependencies of this project, but you can find all of them in the
pyproject.toml
file.
- Loguru - Python logging made(stupidly) simple
- discord.py - An API wrapper for Discord written in Python.
- better-exceptions - Pretty and useful exceptions in Python, automatically.
To use this app with your Discord bot, ensure the following prerequisites are met:
- You have a Discord account.
- Youβve created an application (and bot) through the Discord Developer Portal.
- You have access to your botβs TOKEN.
After completing these steps, fill in the .env.template
file with the necessary configuration details (such as the TOKEN) required by the app.
Caution
Make sure to rename the file to .env
so it is properly recognized by the application.
To enable synchronization with one of your Google Calendars, please follow this guide and configure the environment variables as specified.
If you'd like to run this bot on your machine, here are two versions of how to do so by either doing on your system or using docker.
First, make sure the uv
Python package manager is installed on your system.
Once that's done, clone the repository
git clone https://github.com/leoraclet/ptibot
cd ptibot
Then, install the project dependencies:
uv sync
Tip
You may need to create a virtual environment beforehand:
uv venv
Finally, if you have Make installed, you can launch the development server accordingly.
make run
or you can just run simple commands using
uv run {YOUR_COMMAND}
Ensure that Docker is installed on your system and that the docker
command is available in your terminal.
To start the Docker setup, run:
docker compose up -d
Tip
To rebuild the image from scratch (without using the cache), use the following command:
docker compose build --no-cache
As with local development, you can use the Makefile
to manage Docker-related tasks easily with the following commands:
make up # Build (if needed) and start the containers
make down # Stop and remove containers and associated networks
make build # Build or rebuild the Docker services
make logs # View the output logs from running containers
These projects served as both inspiration and valuable references during the development of this one. Be sure to check them out if you're interested in learning more:
- Deadbeef β A Discord bot created by a friend for a cybersecurity school server.
- discord-reminder-bot β A bot for managing reminders and TODO tasks.
- Python-Discord-Bot-Template β A helpful template for setting up Discord bots with Python.
- GCal2Discord - Syncs events from a Google Calendar to a Discord server
If you encounter an error similar to the following:
...
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1010)
You can resolve this by installing pip-system-certs
in your virtual environment. To do so, run:
uv add pip-system-certs
Caution
If this solution doesn't work for any reason, you can find alternative solutions here on Stack Overflow.
This project is licensed under the MIT License - see the LICENSE file for details.