A comprehensive Discord bot system for tracking user activities with a modern React-based dashboard, automated message scheduling, and AI-powered activity recognition.
- Features
- Prerequisites
- Quick Start
- Architecture
- Discord Bot Commands
- Dashboard Features
- Database Schema
- Docker Deployment
- Development
- Security
- Documentation
- Support
- Discord Bot with Cogs architecture and Slash Commands
- User Tracking: Username, nickname, and role changes with complete history
- Message Scheduler: Automated recurring messages with role pings and embed support
- Activity Recognition: AI-powered game screenshot analysis using OpenAI Vision API
- SQLite Database for persistent data storage with optimized indexes
- REST API with FastAPI for secure data access
- React Dashboard with modern glassmorphism design
- Docker Containers for production-ready deployment
- Real-time Updates and comprehensive event logging
- Dark/Light Mode with system preference detection
- Discord OAuth2 Authentication with role-based access control
- Docker and Docker Compose
- Discord Bot Token (Create Bot)
- Discord Guild (Server) ID
- Discord OAuth2 Application credentials
- OpenAI API Key (for activity recognition feature)
- External Nginx Proxy for SSL termination (optional, for production HTTPS)
git clone <repository-url>
cd Requiem_Managercp .env.example .envEdit the .env file with your credentials:
# Discord Configuration
DISCORD_TOKEN=your_bot_token_here
DISCORD_GUILD_ID=your_guild_id_here
# Discord OAuth2 (for Dashboard Authentication)
DISCORD_CLIENT_ID=your_oauth_client_id_here
DISCORD_CLIENT_SECRET=your_oauth_client_secret_here
# JWT Secret (generate a strong random string)
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
# OpenAI API (for Activity Recognition)
OPENAI_API_KEY=your_openai_api_key_here
# Admin & Moderator Configuration (Discord User/Role IDs)
ADMIN_ROLE_IDS=123456789012345678,987654321098765432
ADMIN_USER_IDS=242292116833697792
MOD_ROLE_IDS=123456789012345678,987654321098765432Production Mode:
# Create external network (one-time setup)
docker network create edge-proxy
# Start all services
docker-compose -f docker-compose.prod.yml up -d --build
# View logs
docker-compose -f docker-compose.prod.yml logs -fDevelopment Mode (with hot-reload):
docker-compose -f docker-compose.dev.yml up -d- Frontend Dashboard: http://localhost:3001
- API Documentation: http://localhost:8000/docs
- API Endpoint: http://localhost:8000
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Edge-Proxy (Nginx) β
β SSL Termination & Reverse Proxy β
β (Separate Project) β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββ¬ββββββββββββββββ
β β
β edge-proxy network β
β β
ββββββββΌβββββββ ββββββββΌβββββββββ
β requiem-api β βrequiem-frontendβ
β (FastAPI) β β (React) β
βββββββββββββββ ββββββββββββββββββ
β
β requiem-network
β
ββββββββΌβββββββ
β requiem-bot β
β (Discord) β
βββββββββββββββ
Networks:
edge-proxy: External network for communication with reverse proxy (HTTPS)requiem-network: Internal network for inter-service communication
Requiem_Manager/
βββ src/
β βββ bot/ # Discord Bot
β β βββ main.py # Bot entry point
β β βββ cogs/ # Bot command modules
β β βββ tracking.py # User tracking commands
β β βββ admin.py # Admin commands
β β βββ scheduler.py # Message scheduler
β β βββ raidhelper.py # Raid helper integration
β β βββ activity_recognition.py # AI-powered screenshot analysis
β βββ database/ # Database layer
β β βββ database.py # SQLite handler with migrations
β βββ api/ # REST API
β βββ main.py # FastAPI server
β βββ auth.py # OAuth2 & JWT authentication
βββ frontend/ # React Dashboard
β βββ src/
β β βββ components/ # Reusable React components
β β βββ pages/ # Dashboard pages
β β βββ contexts/ # React contexts (Auth, Theme)
β β βββ services/ # API service layer
β βββ package.json
βββ docs/ # Documentation
β βββ DISCORD_OAUTH_SETUP.md # OAuth2 setup guide
β βββ ADMIN_CONFIGURATION.md # Admin system configuration
β βββ ACTIVITY_RECOGNITION_GUIDE.md # Activity recognition setup
β βββ MESSAGE_SCHEDULER_GUIDE.md # Message scheduler usage
β βββ CLOUDFLARE_SSL_SETUP.md # SSL certificate setup
β βββ ...
βββ docker-compose.prod.yml # Production containers
βββ docker-compose.dev.yml # Development containers
βββ Dockerfile.bot # Bot container definition
βββ Dockerfile.api # API container definition
βββ Dockerfile.frontend # Frontend container definition
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
/user_stats [user]- Display statistics for a specific user/recent_changes [limit]- Show recent username/nickname changes/role_history <user>- View complete role change history for a user/server_stats- Display comprehensive server statistics/analyze_activity <image1> [image2-5]- Analyze game activity screenshots to extract member names and weekly activity points using AI
Requires Administrator permissions or configured Admin/Mod roles
/sync- Synchronize slash commands with Discord/database_stats- View database statistics and health metrics/cleanup_old_data [days]- Remove data older than specified days/export_user_data <user>- Export complete data for a specific user/cleanup_duplicate_roles- Remove duplicate initial role entries
Requires Administrator permissions or configured Admin/Mod roles
/schedule_list- List all scheduled messages with status/schedule_add- Create a new scheduled message with interval and role pings/schedule_edit <message_id>- Edit an existing scheduled message/schedule_remove <message_id>- Delete a scheduled message/schedule_toggle <message_id>- Enable or disable a scheduled message
π Detailed Guide: See Message Scheduler Documentation
- Main Dashboard: Server overview with real-time statistics and glassmorphism design
- User List: Browse all users with search functionality and role filtering
- User Details: Detailed user profile with statistics and complete history
- Recent Changes: Comprehensive log of username and nickname changes
- Admin Panel: System status, database statistics, and management tools
- Discord OAuth2 integration for secure login
- Role-based access control with configurable admin and moderator roles
- JWT tokens for secure session management
- Protected routes with automatic permission checks
- Refresh token support for seamless sessions
- User joins and leaves server
- Username changes with timestamps
- Nickname changes with before/after values
- Role additions and removals with complete history
- Initial inventory of all existing guild members
- Modern Glassmorphism UI with backdrop blur effects
- Dark/Light mode with automatic system preference detection
- Discord-inspired color palette for familiar user experience
- Smooth animations and hover effects
- Responsive design for desktop, tablet, and mobile
- Interactive user cards with dynamic role displays
- Professional data visualization with charts and graphs
users- User basic information (ID, username, avatar)guild_members- Guild-specific member dataroles- Role information with colors and positionsusername_changes- Complete username change historynickname_changes- Nickname change trackingrole_changes- Role addition and removal eventsjoin_leave_events- Server join and leave trackingscheduled_messages- Automated message scheduling data
Features:
- Optimized with indexes for fast queries
- Automatic schema migrations
- Support for data cleanup and archiving
- Foreign key constraints for data integrity
β οΈ IMPORTANT: The Requiem Manager project uses a separate Edge-Proxy for SSL termination and HTTPS routing.
Setup Steps:
- Set up Edge-Proxy: See Nginx Proxy Project
- Create Edge-Proxy Network:
docker network create edge-proxy - Configure SSL Certificates: Follow Cloudflare SSL Setup Guide
- Start Requiem Manager:
docker-compose -f docker-compose.prod.yml up -d --build
Standard Deployment:
# 1. Create edge-proxy network (one-time setup)
docker network create edge-proxy
# 2. Start all services
docker-compose -f docker-compose.prod.yml up -d --build
# 3. Check logs
docker-compose -f docker-compose.prod.yml logs -f
# 4. Check service status
docker-compose -f docker-compose.prod.yml psFor SSL setup details, see: Cloudflare SSL Setup Guide
Hot-Reload Development Mode:
# Start development environment
docker-compose -f docker-compose.dev.yml up -d
# View logs
docker-compose -f docker-compose.dev.yml logs -f
# Stop services
docker-compose -f docker-compose.dev.yml down- requiem-bot: Discord bot with automatic restart
- requiem-api: FastAPI backend accessible via
edge-proxynetwork - requiem-frontend: React frontend served via
edge-proxynetwork
All containers include health checks for monitoring:
# Check container health
docker ps
# View detailed health status
docker inspect --format='{{json .State.Health}}' requiem-botBackend Setup:
# Install Python dependencies
pip install -r requirements.txt
# Start Discord Bot
python -m src.bot.main
# Start API Server (in separate terminal)
python -m src.api.mainFrontend Setup:
# Navigate to frontend directory
cd frontend
# Install Node.js dependencies
npm install
# Start development server
npm start
# Build for production
npm run buildComplete Environment Variables:
# Discord Bot Configuration
DISCORD_TOKEN=your_discord_bot_token_here
DISCORD_GUILD_ID=your_guild_id_here
# Discord OAuth2 Configuration
DISCORD_CLIENT_ID=your_oauth_client_id_here
DISCORD_CLIENT_SECRET=your_oauth_client_secret_here
DISCORD_REDIRECT_URI=http://localhost:3001/auth/callback
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
# Admin Configuration (comma-separated IDs)
ADMIN_ROLE_IDS=123456789012345678,987654321098765432
ADMIN_USER_IDS=242292116833697792
# Moderator Configuration (comma-separated IDs)
MOD_ROLE_IDS=123456789012345678,987654321098765432
# OpenAI Configuration (for Activity Recognition)
OPENAI_API_KEY=your_openai_api_key_here
# Database Configuration
DATABASE_PATH=./data/tracking.db
# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
# Frontend Configuration
REACT_APP_API_URL=http://localhost:8000
REACT_APP_DEFAULT_GUILD_ID=your_guild_id_here
REACT_APP_DISCORD_CLIENT_ID=your_oauth_client_id_hereLogs are automatically written to the logs/ directory:
# View all container logs
docker-compose -f docker-compose.prod.yml logs -f
# View specific service logs
docker-compose -f docker-compose.prod.yml logs -f bot
docker-compose -f docker-compose.prod.yml logs -f api
docker-compose -f docker-compose.prod.yml logs -f frontend
# View last 100 lines
docker-compose -f docker-compose.prod.yml logs --tail=100 botBot won't start:
- Verify Discord token is correct
- Check bot has required Privileged Gateway Intents enabled:
- Server Members Intent
- Message Content Intent (if using message commands)
- Confirm Guild ID is correct
- Check container logs:
docker-compose logs bot
Commands not showing:
- Use
/synccommand to synchronize slash commands - Wait a few minutes for Discord to propagate commands
- Check bot has
applications.commandsscope in OAuth2 URL
API not reachable:
- Verify port 8000 is not in use by another application
- Check container status:
docker ps - View API logs:
docker-compose logs api - Test health endpoint:
curl http://localhost:8000/health
CORS errors:
- Verify
REACT_APP_API_URLmatches API URL - Check API CORS configuration in
src/api/main.py - Ensure frontend and API are on same domain/port in production
Dashboard won't load:
- Check API is running and accessible
- Verify
REACT_APP_API_URLis correctly set - Check browser console for errors
- View frontend logs:
docker-compose logs frontend
Authentication fails:
- Verify Discord OAuth2 credentials are correct
- Check redirect URI matches exactly (including protocol and port)
- Ensure
JWT_SECRETis set and consistent - Confirm user is a member of the configured guild
- Clear browser cookies and retry
Database errors:
- Check
data/folder exists and has correct permissions - Verify SQLite file is created:
ls -la data/ - Check database logs in container logs
- Try manual database check:
sqlite3 data/tracking.db ".schema"
Migration failures:
- Database migrations run automatically on startup
- Check bot logs for migration errors
- Backup database before manual intervention
- Contact support with error logs
- Optimized SQLite with indexes on frequently queried columns
- Automatic cleanup of old data via Admin Panel
- Container health checks for automatic restart on failure
- Efficient API endpoints with pagination support
- React optimizations using useCallback, useMemo, and lazy loading
- Caching strategies for frequently accessed data
- Connection pooling for database operations
- Environment variables for all sensitive credentials (no hardcoded secrets)
- JWT authentication with token expiration and refresh
- API CORS protection with configurable origins
- Role-based access control for admin features
- Discord OAuth2 for secure user authentication
- SQL injection protection through parameterized queries
- Container security with non-root users (recommended for production)
- Rate limiting on API endpoints (configurable)
- Input validation on all user inputs
Comprehensive guides available in the docs/ folder:
- Discord OAuth2 Setup Guide - Complete OAuth2 configuration
- Admin Configuration Guide - Configure admin and moderator roles
- Cloudflare SSL Setup Guide - Production HTTPS setup
- Activity Recognition Guide - AI-powered screenshot analysis setup
- Message Scheduler Guide - Automated message scheduling usage
- Message Scheduler Changelog - Feature history and updates
- Production Deployment Guide - Detailed production setup (outdated, use this README)
- Scheduler Test Guide - Testing message scheduler functionality
- Activity Recognition Changelog - Feature updates and changes
This project is licensed under the MIT License - see the LICENSE file for details.
Having issues or questions?
- Check Documentation: Review relevant guides in the
docs/folder - Search Issues: Look for similar problems in GitHub Issues
- Create New Issue: If not found, open a new issue with:
- Detailed description of the problem
- Steps to reproduce
- Error messages and logs
- Environment details (OS, Docker version, etc.)
- Provide Logs: Always include relevant logs from affected services
Quick Debug Commands:
# Check all service status
docker-compose -f docker-compose.prod.yml ps
# View all logs
docker-compose -f docker-compose.prod.yml logs -f
# Check specific service
docker-compose -f docker-compose.prod.yml logs bot --tail=50
# Restart all services
docker-compose -f docker-compose.prod.yml restart
# Rebuild specific service
docker-compose -f docker-compose.prod.yml up -d --build botMade with β€οΈ for the Requiem Community