A professional Discord support bot with integrated bug reporting system, ticket management, and secure file storage on Cloudflare R2.
- Bug Report System - Users submit bug reports via Discord modals
- Ticket Management - Automatic unique ticket ID generation (BUG-XXXXX format)
- File Upload - Secure file uploads to Cloudflare R2 cloud storage
- Database - MongoDB for persistent ticket and metadata storage
- Status Dashboard - Real-time system status monitoring
- Notifications - Role-based notification system with configurable mentions
- Error Handling - Comprehensive error logging and recovery mechanisms
Before you start, make sure you have:
- Node.js 18+ (Download here)
- MongoDB (local or cloud instance like MongoDB Atlas)
- Discord Bot Token with proper intents enabled
- Cloudflare R2 bucket (for file storage - optional but recommended)
- Git for version control
git clone https://github.com/KanaparthyPraveen/Alex-support-bot.git
cd Alex-support-botnpm installCopy the example env file and update with your actual credentials:
cp .env.example .envNow open .env and fill in the following variables:
DISCORD_TOKEN=your_discord_bot_token_here
TARGET_IDS=user_id_1,user_id_2,user_id_3
CHANNEL_ID=your_dashboard_channel_id
NOTIFICATION_CHANNEL_IDS=notification_channel_id_1,notification_channel_id_2DISCORD_TOKEN- Get this from Discord Developer PortalTARGET_IDS- Comma-separated list of Discord user IDs to monitorCHANNEL_ID- Channel ID where the status dashboard will be postedNOTIFICATION_CHANNEL_IDS- Channels for notifications (comma-separated)
MONGODB_URI=mongodb://localhost:27017/alex_support- Local MongoDB:
mongodb://localhost:27017/alex_support - MongoDB Atlas Cloud:
mongodb+srv://username:password@cluster.mongodb.net/alex_support
R2_ACCESS_KEY_ID=your_r2_access_key
R2_SECRET_ACCESS_KEY=your_r2_secret_key
R2_BUCKET_NAME=bug-reports
R2_ENDPOINT=https://your-account.r2.cloudflarestorage.comGet these from your Cloudflare R2 bucket settings
ROLE_ID_OUTAGES=role_id_outages
ROLE_ID_UPDATES=role_id_updates
ROLE_ID_STATUS=role_id_status
ROLE_ID_ANNOUNCEMENTS=role_id_announcements
ROLE_ID_CHANGELOGS=role_id_changelogs
ROLE_ID_BIG_ASS_PING=role_id_pingThese are Discord role IDs for targeted notifications. Leave blank if not needed.
Development Mode (with auto-reload):
npm run devProduction Build (compile TypeScript):
npm run build
npm startsrc/
βββ index.ts # Entry point - bot initialization
βββ client.ts # Discord client configuration
βββ config.ts # Environment variables management
βββ database.ts # MongoDB connection setup
βββ dashboard.ts # Status dashboard display logic
βββ embeds.ts # Discord embed builders
βββ buttons.ts # Button interaction handlers
βββ types.ts # TypeScript interfaces & types
β
βββ models/
β βββ Ticket.ts # MongoDB Ticket model
β
βββ schemas/
β βββ BugReport.ts # MongoDB BugReport schema
β
βββ interactions/
β βββ buttons/
β β βββ reportBug.ts # Bug report button handler
β β βββ notifications.ts # Notification settings handler
β βββ modals/
β β βββ productionReportModal.ts # Bug report form
β β βββ bugReportModal.ts # Legacy bug report modal
β βββ handlers/
β β βββ interactionHandler.ts # Main interaction router
β β βββ productionReportHandler.ts # Process bug submissions
β βββ messages/
β βββ attachmentHandler.ts # Handle message attachments
β
βββ services/
β βββ r2Uploader.ts # Cloudflare R2 file upload service
β
βββ scripts/
β βββ verify-fetch.ts # Utility script
β βββ verify-r2.ts # R2 verification script
β
βββ utils/
βββ generateTicketId.ts # Create unique BUG-XXXXX IDs
βββ storage.ts # Storage utility functions
- User clicks "Report Bug" button in Discord
- Modal appears asking for title, description, and optional environment info
- User submits with optional file attachments
- Bot processes:
- Generates unique ticket ID (e.g., BUG-A1B2C)
- Downloads files from Discord CDN
- Uploads files to R2 storage
- Saves ticket metadata to MongoDB
- User receives ticket confirmation with ID for tracking
MongoDB stores:
- Ticket ID, user info, bug description
- File URLs from R2
- Status (OPEN, IN_PROGRESS, RESOLVED, CLOSED)
- Creation timestamp
R2 stores:
- Actual bug report files
- Organized by ticket ID:
tickets/BUG-A1B2C/filename.ext
- Click the "π Report a Bug" button in Discord
- Fill in the bug title and description
- (Optional) Attach files to your Discord message before submitting
- Submit the modal
- Check:
- Bot's Discord reply with ticket ID
- MongoDB for new ticket record
- R2 bucket for uploaded files
- Check Discord token is correct in
.env - Ensure bot has "Send Messages" permission in the channel
- Verify privileged intents are enabled in Developer Portal
- Verify
MONGODB_URIis correct - Check MongoDB server is running (local) or connection string is valid (Atlas)
- Ensure network access is allowed if using MongoDB Atlas
- Double-check R2 credentials in
.env - Verify bucket name is correct
- Check R2 endpoint URL format
- Ensure
R2_ACCESS_KEY_IDandR2_SECRET_ACCESS_KEYare valid - Check bucket has proper permissions
- Verify file size is not too large
npm run dev # Development mode with ts-node
npm run build # Compile TypeScript to JavaScript
npm start # Run production build (after npm run build)- Never commit
.envto version control - Use
.env.exampleas a template - Keep Discord token, R2 keys, and MongoDB URI private
- Rotate credentials periodically
- Use environment-specific values for different environments
- Separation of Concerns - Each module has a single responsibility
- Type Safety - Full TypeScript for better development experience
- Error Handling - Comprehensive error catching and logging
- Async/Await - Modern async patterns throughout
- MongoDB Schemas - Structured data models with validation
btn_bug_report- Opens bug report modalbtn_troubleshoot- Shows troubleshooting optionsbtn_notifications_menu- Notification settingsbtn_role_*- Role toggle buttons
- Production bug report modal
- Legacy bug report modal (backward compatible)
- Fork the repository
- Create a feature branch
- Make your changes
- Commit with clear messages
- Push and create a pull request
ISC
For issues or questions:
- Check the troubleshooting section above
- Review MongoDB and R2 documentation
- Create an issue on GitHub with detailed steps to reproduce
Built with β€οΈ for the Alex Music Bot community