A Discord bot that enables seamless ticket creation and management between users and server administrators through private threads. Built with mini-interaction framework for optimal performance and reliability.
- Ticket Creation: Users can create support tickets from any server the bot is in
- Private Threads: All tickets are created as private Discord threads for secure communication
- Staff Management: Server admins can assign staff roles for ticket notifications
- Channel Control: Customizable ticket creation channels per server
- OAuth Integration: Secure Discord OAuth2 for user authentication
- Database Storage: MongoDB integration for persistent data storage
- Real-time Updates: Instant notifications and thread management
- Node.js 18+
- MongoDB database
- Discord Application with bot token
- Vercel account (for deployment)
-
Clone the repository
git clone https://github.com/neodevils/thread-mail-discord.git cd thread-mail-discord -
Install dependencies
npm install
-
Environment Setup
cp .env.example .env
Fill in your environment variables:
DISCORD_APPLICATION_ID=your_app_id DISCORD_BOT_TOKEN=your_bot_token DISCORD_PUBLIC_KEY=your_public_key DISCORD_REDIRECT_URI=your_redirect_uri DATABASE_TYPE=mongodb MONGODB_URI=your_mongodb_connection_string
-
Register Discord commands
npm run build
-
Start development server
npm run production
ThreadMail includes the following Discord slash commands:
/create- Create a new support ticket/send- Send messages in active tickets/close- Close and archive tickets/manage- Server administration settings
-
Install Vercel CLI
npm install -g vercel
-
Login and link project
vercel login vercel link
-
Deploy
vercel --prod
Set these in your Vercel dashboard or .env file:
| Variable | Description | Required |
|---|---|---|
DISCORD_APPLICATION_ID |
Your Discord application ID | β |
DISCORD_BOT_TOKEN |
Bot token from Discord Developer Portal | β |
DISCORD_PUBLIC_KEY |
Public key for Discord interactions | β |
DISCORD_REDIRECT_URI |
OAuth2 redirect URI | β |
MONGODB_URI |
MongoDB connection string | β |
DATABASE_TYPE |
Database type (mongodb) | β |
-
Create Discord Application
- Go to Discord Developer Portal
- Create a new application
- Copy Application ID, Public Key, and generate Bot Token
-
Bot Permissions
Send MessagesUse Slash CommandsCreate Private ThreadsManage ThreadsRead Message History
-
Invite Bot
https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&permissions=268435456&scope=bot%20applications.commands
- Invite the bot to your server
- Set staff role (optional):
/manage staff set @role - Set custom channel (optional):
/manage channel set #channel - View settings:
/manage staff viewor/manage channel view
- Authorize: Visit the OAuth URL or use
/authorize-account - Create ticket: Use
/createand select target server - Send messages: Use
/sendcommand in DMs - Close ticket: Use
/closewhen done
- Terms of Service - User agreements and responsibilities
- Privacy Policy - Data collection and privacy practices
- Bot not responding: Check bot permissions and ensure it's online
- Ticket creation fails: Verify bot has "Create Private Threads" permission
- Database errors: Check MongoDB connection and credentials
- OAuth issues: Verify redirect URI matches your domain
Set NODE_ENV=development for additional logging (not recommended for production).
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Documentation: This README and inline code comments
- Community: Discord support channels
Built with β€οΈ using mini-interaction