Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/notchum/discord-bot-template
Discord Bot Template / Boilerplate
https://github.com/notchum/discord-bot-template
discord discord-bot discord-server discordapp disnake mongodb python slash-commands template
Last synced: 8 days ago
JSON representation
Discord Bot Template / Boilerplate
- Host: GitHub
- URL: https://github.com/notchum/discord-bot-template
- Owner: notchum
- License: gpl-3.0
- Created: 2024-03-01T17:19:09.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-07T20:32:48.000Z (6 months ago)
- Last Synced: 2024-09-21T18:25:23.041Z (12 days ago)
- Topics: discord, discord-bot, discord-server, discordapp, disnake, mongodb, python, slash-commands, template
- Language: Python
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Discord Bot Template
[![Tests](https://github.com/notchum/discord-bot-template/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/notchum/discord-bot-template/actions/workflows/test.yml)
Discord bot with slash commands. It uses [MongoDB](https://docs.mongodb.com/) database and [disnake](https://github.com/DisnakeDev/disnake) Discord API wrapper.
### Requirements
- [Python](https://www.python.org/downloads/)
- [MongoDB](https://docs.mongodb.com/manual/installation/)### How to use this template
To use this template as your project starting point, click "Use this template" at the top of this page, or click [here](https://github.com/notchum/discord-bot-template/generate).
### Feature highlights
* Asynchronous support for files (via [aiofiles](https://github.com/Tinche/aiofiles)),
HTTP requests (via [aiohttp](https://github.com/aio-libs/aiohttp)),
and MongoDB drivers (via [motor](https://github.com/mongodb/motor) & [Beanie](https://github.com/roman-right/beanie))
* Environment configuration with [python-dotenv](https://github.com/theskumar/python-dotenv)
* Logs via [loguru](https://github.com/delgan/loguru)
* Error handling
* Docker image build workflow to push images to [Docker Hub](https://hub.docker.com/)
* Temporary file directory with scheduled clean-up### Project structure
```bash
├── requirements.txt
├── bot.py # The `MyBot` class
├── launcher.py # Entry point to launch the bot
├── .env # Environment variables for bot configuration (renamed from .env.example)
├── cogs
│ ├── admin.py # Slash commands for guild administrators
│ ├── commands.py # Example cog with some example slash commands
│ ├── events.py # Discord event listeners
│ ├── owner.py # Slash commands for the bot owner only
│ └── tasks.py # Disnake scheduled background tasks
├── helpers
│ ├── __init__.py
│ ├── embeds.py # Common Discord embed templates
│ └── utilities.py # General utilities
├── models
│ ├── __init__.py
│ ├── guild.py # Example ODM model for guilds
│ └── settings.py # ODM model for global bot settings
├── views
│ ├── __init__.py
│ └── paginator.py # Example view implementing embed pages
├── Dockerfile
├── README.md
├── DEVELOPMENT.md
└── LICENSE
```### Todo
- [ ] Tests with pytest
- [ ] CI based on Github actions
- [ ] Dependabot configuration
- [ ] Instructions to create bot application with correct permissions
- [ ] Dockerfile
- [ ] Instructions to set up docker hub secrets in Github## Contributing
Contributors are welcome, please fork and send pull requests! If you find a bug
or have any ideas on how to improve this project please submit an issue.## Development
### Code formatting
[ruff](https://github.com/astral-sh/ruff) is used for code formatting. Always format the code with ruff before submitting a pull request.
### Testing
``` sh
# Inside the project root (directory containing this file)
python -m venv venv && source ./venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-test.txt
mypy
pytest
ruff format .
```