new file: .gitignore new file: Dockerfile new file: README.md new file: bot.py new file: requirements.txt
199 lines
4.6 KiB
Markdown
199 lines
4.6 KiB
Markdown
# Discord Ticket Management Bot
|
|
|
|
A Discord bot for creating and managing project update tickets with integration to devanturas.net projects.
|
|
|
|
## Features
|
|
|
|
- ✅ Create tickets with slash commands
|
|
- 📋 Track project updates from devanturas.net
|
|
- 🔄 Update ticket status (Pending, In Progress, Completed, Cancelled)
|
|
- 📦 Automatic archiving of completed tickets
|
|
- 🎫 List and view all active tickets
|
|
- 📊 Beautiful embed messages with ticket information
|
|
|
|
## Setup Instructions
|
|
|
|
### 1. Create a Discord Bot
|
|
|
|
1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
|
|
2. Click "New Application" and give it a name
|
|
3. Go to the "Bot" section
|
|
4. Click "Add Bot"
|
|
5. Under "Privileged Gateway Intents", enable:
|
|
- MESSAGE CONTENT INTENT
|
|
- SERVER MEMBERS INTENT
|
|
6. Click "Reset Token" and copy your bot token
|
|
|
|
### 2. Install Dependencies
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
### 3. Configure the Bot
|
|
|
|
1. Copy `.env.example` to `.env`:
|
|
```bash
|
|
copy .env.example .env
|
|
```
|
|
|
|
2. Edit `.env` and add your bot token:
|
|
```
|
|
DISCORD_TOKEN=your_bot_token_here
|
|
```
|
|
|
|
### 4. Invite the Bot to Your Server
|
|
|
|
1. In the Discord Developer Portal, go to "OAuth2" > "URL Generator"
|
|
2. Select scopes:
|
|
- `bot`
|
|
- `applications.commands`
|
|
3. Select bot permissions:
|
|
- Send Messages
|
|
- Embed Links
|
|
- Read Message History
|
|
- Manage Messages
|
|
4. Copy the generated URL and open it in your browser
|
|
5. Select your server and authorize
|
|
|
|
### 5. Run the Bot
|
|
|
|
```bash
|
|
python bot.py
|
|
```
|
|
|
|
### 6. Configure Channels
|
|
|
|
In Discord, use the `/setup` command to configure the channels:
|
|
|
|
```
|
|
/setup active_channel:#active-tickets archive_channel:#archived-tickets
|
|
```
|
|
|
|
## Commands
|
|
|
|
### `/ticket` - Create a New Ticket
|
|
|
|
Create a new project update ticket.
|
|
|
|
**Parameters:**
|
|
- `message_id`: Discord message ID to reference
|
|
- `project_name`: Project name from devanturas.net/versions
|
|
- `title`: Brief description of the update
|
|
|
|
**Example:**
|
|
```
|
|
/ticket message_id:123456789 project_name:MyProject title:Version 2.0 Update
|
|
```
|
|
|
|
### `/status` - Update Ticket Status
|
|
|
|
Update the status of an existing ticket.
|
|
|
|
**Parameters:**
|
|
- `ticket_id`: The ticket ID (e.g., TICKET-0001)
|
|
- `new_status`: Choose from:
|
|
- ⏳ Pending
|
|
- 🔄 In Progress
|
|
- ✅ Completed
|
|
- ❌ Cancelled
|
|
|
|
**Example:**
|
|
```
|
|
/status ticket_id:TICKET-0001 new_status:In Progress
|
|
```
|
|
|
|
**Note:** When a ticket is marked as "Completed", it will automatically be moved to the archive channel.
|
|
|
|
### `/list` - View Active Tickets
|
|
|
|
Lists all currently active (non-archived) tickets.
|
|
|
|
**Example:**
|
|
```
|
|
/list
|
|
```
|
|
|
|
### `/info` - Get Ticket Details
|
|
|
|
Get detailed information about a specific ticket.
|
|
|
|
**Parameters:**
|
|
- `ticket_id`: The ticket ID to view
|
|
|
|
**Example:**
|
|
```
|
|
/info ticket_id:TICKET-0001
|
|
```
|
|
|
|
### `/setup` - Configure Bot Channels
|
|
|
|
Configure the active and archive channels for tickets (Admin only).
|
|
|
|
**Parameters:**
|
|
- `active_channel`: Channel for active tickets
|
|
- `archive_channel`: Channel for completed tickets
|
|
|
|
**Example:**
|
|
```
|
|
/setup active_channel:#active-tickets archive_channel:#archived-tickets
|
|
```
|
|
|
|
## Ticket Workflow
|
|
|
|
1. **Create**: Use `/ticket` to create a new ticket in the active channel
|
|
2. **Update**: Use `/status` to update the ticket status as you work
|
|
3. **Complete**: Mark ticket as "Completed" to automatically archive it
|
|
4. **Archive**: Completed tickets are moved to the archive channel
|
|
|
|
## Project Integration
|
|
|
|
The bot integrates with devanturas.net:
|
|
- All projects: https://devanturas.net/versions
|
|
- Specific project: https://devanturas.net/projects/{project_name}
|
|
|
|
Each ticket embed includes direct links to the project pages.
|
|
|
|
## Data Storage
|
|
|
|
Currently, tickets are stored in memory. For production use, consider implementing:
|
|
- Database storage (SQLite, PostgreSQL, etc.)
|
|
- Persistent ticket data between restarts
|
|
- Backup and recovery mechanisms
|
|
|
|
## Docker Support
|
|
|
|
Build and run with Docker:
|
|
|
|
```bash
|
|
# Build the image
|
|
docker build -t discord-ticket-bot .
|
|
|
|
# Run the container
|
|
docker run -d --name ticket-bot --env-file .env discord-ticket-bot
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Bot doesn't respond to commands
|
|
- Make sure the bot is online
|
|
- Check that you've enabled the correct intents in the Developer Portal
|
|
- Verify the bot has permissions in your server
|
|
|
|
### Commands don't appear
|
|
- Wait a few minutes for commands to sync
|
|
- Try kicking and re-inviting the bot
|
|
- Check the bot logs for sync errors
|
|
|
|
### Tickets aren't archiving
|
|
- Verify you've run `/setup` to configure channels
|
|
- Check that the bot has permissions in both channels
|
|
|
|
## License
|
|
|
|
MIT License - feel free to modify and use for your projects!
|
|
|
|
## Author
|
|
|
|
Created for SimolZimol
|