A containerized Discord bot that allows server administrators to create GitHub issues directly from Discord messages using slash commands. Built with modern Python tooling (uv) and designed for container deployment.
- π€ Discord Integration: Create GitHub issues from Discord messages via
/create-issueslash command - π Permission Control: Administrator-only access to issue creation
- π·οΈ Flexible Labeling: Add custom labels and assignees to issues
- π Database Tracking: SQLite database to link Discord messages with GitHub issues
- π³ Container Ready: Optimized Docker containers with multi-stage builds
- π§ Modern Tooling: Built with uv for fast dependency management
- π Health Monitoring: Built-in health checks for container orchestration
- π‘οΈ Security: Non-root container execution and graceful shutdown handling
- Docker and Docker Compose
- Discord Bot Token
- GitHub Personal Access Token with
repopermissions - Target GitHub repository
git clone <your-repository-url>
cd discord-to-github-issues-bot
# Copy environment template
cp .env.example .env
# Edit .env with your tokens and repository details# Build and start the bot
docker-compose up -d
# View logs
docker-compose logs -f discord-bot
# Stop the bot
docker-compose down- Python 3.8+
- uv package manager
# Install dependencies
uv sync
# Copy environment template
cp .env.example .env
# Edit .env with your configuration
# Run the bot
uv run python -m src.bot
# Run tests
uv run pytest
# Run with development dependencies
uv sync --dev
uv run pytest --cov=src| Variable | Required | Description | Example |
|---|---|---|---|
DISCORD_TOKEN |
β | Discord bot token | MTEx... |
GITHUB_TOKEN |
β | GitHub personal access token | ghp_... |
GITHUB_REPO_OWNER |
β | GitHub repository owner | your-username |
GITHUB_REPO_NAME |
β | GitHub repository name | your-repo |
DATABASE_PATH |
β | Database file path | /app/data/bot_data.db |
- Create a new application at Discord Developer Portal
- Create a bot user and copy the token
- Enable the following bot permissions:
- Read Messages/View Channels
- Send Messages
- Use Slash Commands
- Invite the bot to your server with Administrator permissions
- Create a Personal Access Token with
reposcope - Ensure the token has access to the target repository
Once the bot is running and invited to your Discord server:
Create a GitHub issue from any Discord message:
/create-issue message_id:123456789 title:"Bug Report" labels:"bug,urgent" assignees:"username1,username2"
Parameters:
message_id(required): Discord message ID to convert to issuetitle(required): GitHub issue titlelabels(optional): Comma-separated list of labelsassignees(optional): Comma-separated list of GitHub usernames
Check bot health status (admin only):
/health
# Build the image
docker build -t discord-github-bot .
# Run with environment variables
docker run -d \
--name discord-bot \
-e DISCORD_TOKEN="your_token" \
-e GITHUB_TOKEN="your_token" \
-e GITHUB_REPO_OWNER="owner" \
-e GITHUB_REPO_NAME="repo" \
-v bot_data:/app/data \
discord-github-botFor production environments, consider:
- Database: Use PostgreSQL instead of SQLite (uncomment postgres service in docker-compose.yml)
- Secrets Management: Use Docker secrets or Kubernetes secrets
- Monitoring: Configure logging aggregation and health check endpoints
- Resource Limits: Adjust memory and CPU limits in docker-compose.yml
- Backup: Regular database backups if using SQLite with persistent volumes
apiVersion: apps/v1
kind: Deployment
metadata:
name: discord-github-bot
spec:
replicas: 1
selector:
matchLabels:
app: discord-github-bot
template:
metadata:
labels:
app: discord-github-bot
spec:
containers:
- name: bot
image: discord-github-bot:latest
env:
- name: DISCORD_TOKEN
valueFrom:
secretKeyRef:
name: bot-secrets
key: discord-token
# ... other env vars
volumeMounts:
- name: data
mountPath: /app/data
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
volumes:
- name: data
persistentVolumeClaim:
claimName: bot-data-pvcdiscord-to-github-issues-bot/
βββ src/
β βββ db/
β β βββ database.py # Database operations
β βββ bot.py # Main bot logic
βββ tests/
β βββ __init__.py
β βββ test_bot.py # Test cases
βββ Dockerfile # Container definition
βββ docker-compose.yml # Local development setup
βββ pyproject.toml # Python dependencies and metadata
βββ .env.example # Environment template
βββ README.md
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run tests:
uv run pytest - Submit a pull request
Run the test suite:
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=src --cov-report=html
# Run specific test file
uv run pytest tests/test_bot.py -v-
Bot not responding to slash commands
- Ensure the bot has been invited with proper permissions
- Check that slash commands are synced (see bot logs)
- Verify the bot token is correct
-
GitHub API errors
- Verify GitHub token has
repopermissions - Check repository owner/name are correct
- Ensure the token hasn't expired
- Verify GitHub token has
-
Database errors
- Check that the data directory exists and is writable
- For containers, verify volume mounting is correct
-
Container startup issues
- Check container logs:
docker-compose logs discord-bot - Verify all environment variables are set
- Ensure Docker has enough resources allocated
- Check container logs:
View bot logs:
# Docker Compose
docker-compose logs -f discord-bot
# Docker
docker logs -f <container-id>
# Local development
# Logs output to stdout with structured formattingThis project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the troubleshooting section above
- Search existing GitHub issues
- Create a new issue with detailed information about your setup and the problem