A Discord bot that allows users to send direct messages to create support tickets. Staff can respond to tickets in a designated support channel, and messages are automatically forwarded between users and staff.
- Direct Message Support: Users can DM the bot to create support tickets
- Automatic Ticket Creation: Creates tickets in a designated support channel
- Message Forwarding: Forwards messages between users and staff
- SQLite Database: Stores ticket and message history
- Docker Support: Easy deployment with Docker and Docker Compose
- Staff Commands: Commands to manage and close tickets
- Python 3.12+
- Discord Bot Token
- Discord Server with appropriate permissions
git clone <repository-url>
cd discord-mod-mailpip install -r requirements.txtCopy the environment template and fill in your values:
cp .env.template .envEdit .env file with your configuration:
DISCORD_TOKEN=your_discord_bot_token_here
SUPPORT_TICKET_PARENT=your_support_channel_id_here
DATABASE_PATH=./data/modmail.db
BOT_PREFIX=!- Go to Discord Developer Portal
- Create a new application
- Go to the "Bot" section
- Create a bot and copy the token
- Enable the following intents:
- Message Content Intent
- Server Members Intent (if needed)
- Invite the bot to your server with the following permissions:
- Send Messages
- Read Message History
- Manage Messages
- Embed Links
- Read Messages
# Using Makefile (recommended)
make run
# Or directly
python bot.py# Using Makefile (recommended)
make up
# Or directly
docker-compose up -dThe project includes a Makefile for easy development and deployment:
# Setup and installation
make setup # Set up the project
make install # Install dependencies
make dev # Complete development setup
# Development
make run # Run the bot
make test # Run tests
make lint # Run linting
make format # Format code
# Docker
make build # Build Docker image
make up # Start with Docker Compose
make down # Stop the bot
make logs # View logs
make restart # Quick restart
# Maintenance
make clean # Clean up files
make status # Check bot status- Send a direct message to the bot
- The bot will create a support ticket in the designated channel
- Staff will respond in the support channel
- Continue the conversation by replying to the bot's messages
- View Active Tickets:
!tickets- Lists all active tickets - Close Ticket:
!close [user_id]- Closes a ticket (current channel or by user ID) - Add User to Ticket:
!adduser <@user|user_id>- Adds a user to the current ticket - Remove User from Ticket:
!removeuser <@user|user_id>- Removes a user from the current ticket - Ticket Information:
!ticketinfo- Shows information about the current ticket - Respond to Tickets: Reply to messages in the support channel to respond to users
The bot uses SQLite to store:
- Tickets: User ID, Channel ID, Creation time, Active status
- Ticket Users: Multiple users per ticket (many-to-many relationship)
- Messages: Message content, User ID, Direction (user/staff), Timestamps
The bot is containerized for easy deployment:
# Build and run
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the bot
docker-compose down| Variable | Description | Required |
|---|---|---|
DISCORD_TOKEN |
Discord bot token | Yes |
SUPPORT_TICKET_PARENT |
Channel ID for support tickets | Yes |
DATABASE_PATH |
Path to SQLite database | No (default: ./data/modmail.db) |
BOT_PREFIX |
Command prefix | No (default: !) |
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License. See LICENSE for more information.