A production-ready, modular, and sharding-safe Discord logger built with discord.py 2.0+.
Key features include per-guild isolated logging, suspicion heuristics, database log rotation (SQLite), and optional Google Drive integration.
- Modular Logging: 8+ distinct logging modules (Message Delete, Edit, Join, Leave, Voice, Role, Channel, Error) that can be enabled/disabled per guild.
- Per-Guild Isolation: Configurations and logs are strictly isolated.
- Log Rotation: Automatically keeps only the latest 50 logs per guild to save space.
- Suspicious Activity Detection: Detects spam deletes/edits/joins and flags them in logs.
- Slash Commands: Full setup and management via
/setup,/log, and/export. - Exports: Export logs to a JSON file, with optional Google Drive upload.
- Sharding: Built on
AutoShardedBotfor scalability. - Docker Ready: Includes production-grade Dockerfile with non-root user.
.
├── bot.py # Entry point
├── config.py # Configuration management
├── database/ # Database layer (SQLite + Rotation Logic)
├── logging_modules/ # Independent logging modules
├── commands/ # Slash commands
├── utils/ # Utilities (Logger, Drive, Suspicion)
├── Dockerfile # Deployment
└── requirements.txt # Dependencies
- Python 3.11+
- Discord Bot Token (with Message Content, Server Members, and Presence Intents enabled)
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Configure Environment:
Copy
.env.exampleto.envand fill in your details.DISCORD_TOKEN=your_token DRIVE_CREDS_B64=base64_encoded_service_account_json (Optional) DRIVE_FOLDER_ID=your_folder_id (Optional)
- Run the bot:
python bot.py
- Build the image:
docker build -t discord-bot . - Run the container:
Note: You might want to mount the database path if you change
docker run -d --name my-bot --env-file .env -v $(pwd)/data:/app/data discord-botDB_PATHindatabase/core.pyto a persistent volume location.
1.R Deploy from github
Make sure it's uploaded a public or private repo, and that railway has access to it.
Deploying should be as easy as adding the ENV variables and making sure RAILPACK is set.
If any problems occur, check the logs and open an issue on github. I'll try my best to help you.
The bot requires the following permissions to function fully:
- Manage Channels: For
/setup complex. - View Audit Log: For more detailed logging (future expansion).
- Send Messages / Embed Links: For logging.
- Manage Webhooks: (Optional) if using webhook logging in future.
To enable export uploads:
- Create a Google Cloud Service Account.
- Download the JSON key.
- Base64 encode the content of the JSON file:
cat service-account.json | base64 - Set the result as
DRIVE_CREDS_B64in.env. - Share your target Drive folder with the Service Account email.
- Set
DRIVE_FOLDER_IDin.env.
The bot automatically uses AutoShardedBot. You can force a specific shard count using the SHARD_COUNT env var, but leaving it to default is recommended for most use cases.
- Make/copy a token helper for the google drive stuff
- Add signal handlers for when Railways shuts the bot down
- this is mainly for housekeeping and immediately backing up the database
- Make the code a bit more readable
- Make the logger more dynamic and actually colored
This project is licensed under the GNUv3 License - see the LICENSE file for details.
If you have any questions or need support, feel free to open an issue on github. I'll try my best to help you.
Or you can contact me thru discord at _izacarlos