Release Notes | Dashboard Overview | Documentation Wiki
Aszune AI Bot is a professional Discord bot that combines advanced AI conversation capabilities with comprehensive analytics and monitoring features. Built for gaming communities, it provides lore, guides, and advice using the Perplexity API's sonar model while offering real-time performance dashboards and server analytics directly within Discord.
- π€ AI-Powered Conversations - Context-aware chat using Perplexity API's sonar model
- π Web Dashboard - Real-time monitoring with logs, services, network status, and configuration
- β° Smart Reminders - Natural language reminder scheduling with Discord notifications
- π Analytics - Server analytics, user engagement metrics, and performance monitoring
- π Raspberry Pi Optimized - Specialized optimizations for resource-constrained devices
Current Status: 1,700+ tests passing β 70%+ coverage thresholds
- Features
- Installation
- Usage
- Bot Commands
- Web Dashboard
- Analytics & Monitoring
- Project Structure
- Code Quality
- Testing & Coverage
- Troubleshooting
- Contributing
- π Rate Limiting: Prevents users from spamming the bot by enforcing a short cooldown between messages.
- π Help Command:
/help- list all available commands and usage - π§Ύ Conversation Summary:
/summary- generate a summary of your current conversation - π Text Summarisation:
/summarise <text>- summarise any provided text - π Stats Tracking:
/stats- view your usage statistics - β° Reminder System:
/remind,/reminders,/cancelreminder- AI-powered natural language reminders - π Analytics:
/analytics,/dashboard,/resources,/cache- comprehensive monitoring - π€ User Info:
/userinfo [user]- detailed user information with badges, roles, and activity - π Server Info:
/serverinfo- comprehensive server statistics and features - π¬π§ UK English Responses: All bot replies use UK English spelling and phrasing
- π Slash Command Support: All commands available as modern Discord slash commands
- π§ͺ Comprehensive Testing: 1,800+ tests with 70%+ coverage on critical components
- π Web Dashboard: Optional Express + Socket.io dashboard with live metrics
- πΎ Persistent Storage: SQLite database for conversation history and user analytics
- π Raspberry Pi Optimised: Specialised performance optimisations for Pi 3 to Pi 5 (primary deployment target: Pi 5)
- π‘οΈ Code Quality: QLTY integration with 94.8% ESLint fix rate and systematic complexity reduction
The web dashboard provides comprehensive monitoring and management:
- Real-Time Log Viewer: Live log streaming with filtering, search, and export
- Service Status: Monitor and control services (PM2 for the bot; systemd where available)
- Configuration Editor: Safe .env and config.js editing with validation
- Network Status: Interface monitoring, connectivity checks, public IP detection
- Reminder Management: Create, view, edit, and manage reminders via web UI
Access: http://localhost:3000 while the bot is running
For detailed API reference and technical specifications, see DASHBOARD-API-REFERENCE-v1.9.0.md.
- Node.js v20.18.1 or later
- A Discord bot token (from the Discord Developer Portal)
- A valid Perplexity AI API key
-
Clone the repository
git clone https://github.com/powerfulqa/aszune-ai-bot.git cd aszune-ai-bot -
Install dependencies
npm install
-
Create a
.envfileDISCORD_BOT_TOKEN=your_discord_bot_token_here PERPLEXITY_API_KEY=your_perplexity_api_key_here
-
Database Setup (Automatic)
The bot automatically creates and manages a SQLite database:
- Auto-created: Database file created automatically on first run
- Location:
./data/bot.db(configurable viaDB_PATH) - No manual setup required: The bot handles all database initialization
node src/index.jsYou should see:
Discord bot is online!
Your bot should now appear online in your Discord server.
For optimal performance on Raspberry Pi, use the provided script:
# Make the script executable
chmod +x start-pi-optimized.sh
# Run with optimisations
./start-pi-optimized.shThis script applies several performance optimisations:
- Sets memory limits appropriate for your Pi model
- Reduces CPU and memory usage
- Optimises network connections
- Configures compact mode for responses
For more details on Pi optimisations, see the Raspberry Pi Optimisation Guide.
PM2 keeps the bot alive in the background and restarts it on crashes or reboots.
To run the bot with full Raspberry Pi optimisations, use the provided shell script to apply Pi
settings and start PM2 using ecosystem.config.js:
sudo ./start-pi-optimized.sh
pm2 startup
pm2 saveThis ensures all Pi-specific environment variables and system-level tweaks are applied before starting the bot, and enables automatic restart after a reboot.
Note: Running pm2 start src/index.js will NOT apply Pi optimisations.
- Access:
http://localhost:3000while the bot is running - Details: see
wiki/Dashboard-Features-Complete.md(feature overview) anddocs/DASHBOARD-API-REFERENCE-v1.9.0.md(API reference)
| Command | Description |
|---|---|
/help |
Shows a list of available commands and usage |
/clearhistory |
Clears your conversation history |
/summary |
Summarises your current conversation in UK English |
/summarise <text> |
Summarises any provided text in UK English |
/stats |
Shows your usage stats (messages sent, summaries requested) |
| Command | Description |
|---|---|
/userinfo |
Display detailed information about a user |
/serverinfo |
Display detailed information about the current server |
| Command | Description |
|---|---|
/remind |
Set a reminder with natural language time parsing |
/reminders |
List all your active reminders |
/cancelreminder |
Cancel a specific reminder by ID |
| Command | Description |
|---|---|
/analytics |
Show Discord server analytics and performance insights |
/dashboard |
Display comprehensive performance dashboard with real-time data |
/resources |
View resource optimisation status and recommendations |
/cache |
Display cache statistics and performance metrics (Fixed v1.6.5) |
Note: All commands are available as modern Discord slash commands.
Version 1.6.0 introduces comprehensive analytics accessible directly within Discord:
- Live Member Data: Real Discord server statistics with timeout protection (v1.6.1)
- Active User Counts: Live online/idle/dnd member filtering (e.g., "Active Users: 102")
- Server Statistics: Total members, bot counts, human member ratios
- Presence Detection: Real-time member activity status from Discord API
- Fallback Protection: Intelligent estimates when Discord API is slow or unavailable
- Consistent Data: Same Discord member counts as
/analyticsfor reliability (v1.6.1) - System Metrics: Real-time CPU, memory, and network utilization
- Performance Correlation: System load analysis with actual Discord server activity
- Resource Optimization: Performance recommendations based on real usage patterns
- Timeout Protection: 5-second response guarantee with graceful fallbacks
- Resource Analysis: Detailed system resource usage and optimization opportunities
- Performance Recommendations: Automated suggestions for improving bot performance
- Capacity Planning: Usage projections and scaling recommendations
- System Health: Comprehensive health assessments and maintenance guidance
- Performance Metrics: Hit rate, cache hits/misses, operation counts
- Memory Usage: Current cache memory usage and limits (e.g., "0 B / 50 MB")
- Configuration: Eviction strategy and uptime information (e.g., "Strategy: hybrid, Uptime: 28s")
- Operations Tracking: Sets, deletes, evictions statistics
- Complete Field Coverage: All statistics display proper values (no more "undefined")
- No External Tools Required: All monitoring accessible within Discord
- Proactive Management: Early warning system for issues
- Data-Driven Decisions: Usage analytics for community optimization
- Cost Reduction: Eliminates need for third-party monitoring services
- Complete Control: Self-hosted solution with full data ownership
aszune-ai-bot/
βββ src/
β βββ index.js # Main entry point
β βββ commands/ # Command handlers (slash commands only)
β β βββ index.js # Unified command handler
β β βββ reminder.js # Reminder command handler
β βββ config/ # Configuration settings
β β βββ config.js # Global configuration
β βββ services/ # API and core services
β β βββ api-client.js # HTTP requests and API communication
β β βββ cache-manager.js # Response caching and cleanup management
β β βββ chat.js # Chat message handler
β β βββ database.js # SQLite database service with reminder support
β β βββ perplexity-secure.js # Perplexity API service
β β βββ reminder-service.js # Reminder scheduling and management
β β βββ response-processor.js # API response processing and formatting
β β βββ storage.js # Data storage service
β β βββ throttling-service.js # Rate limiting and connection throttling
β βββ utils/ # Utility functions and helpers
β βββ cache-pruner.js # Cache cleanup utilities
β βββ connection-throttler.js # Connection throttling
β βββ conversation.js # Conversation management
β βββ debouncer.js # Function debouncing
β βββ discord-analytics.js # Discord analytics utilities
β βββ emoji.js # Emoji processing
β βββ enhanced-cache.js # Enhanced caching
β βββ enhanced-conversation-context.js # Conversation context
β βββ error-handler.js # Error handling utilities
β βββ input-validator.js # Input validation and sanitization
β βββ lazy-loader.js # Lazy loading utilities
β βββ logger.js # Logging utilities
β βββ memory-monitor.js # Memory monitoring and GC
β βββ message-chunker.js # Message chunking
β βββ message-chunking/ # Enhanced chunking system
β β βββ index.js # Main chunking coordinator
β β βββ chunk-boundary-handler.js
β β βββ source-reference-processor.js
β β βββ url-formatter.js
β βββ message-formatter.js # Message formatting
β βββ natural-language-reminder.js # AI-powered reminder detection
β βββ performance-dashboard.js # Performance dashboard
β βββ performance-monitor.js # Performance tracking
β βββ performance-tracker.js # Performance metrics
β βββ pi-detector.js # Raspberry Pi detection
β βββ resource-optimizer.js # Resource optimization
β βββ security-monitor.js # Security monitoring
β βββ testUtils.js # Test utilities
β βββ time-parser.js # Advanced time parsing for reminders
βββ data/ # Persistent data storage
β βββ bot.db # SQLite database (auto-created)
β βββ question_cache.json # Response cache
β βββ test.db # Test database
β βββ user_stats.json # User statistics (legacy)
βββ docs/ # Version-specific documentation
βββ scripts/ # Development and utility scripts
β βββ check-triggers.js # Database trigger validation
β βββ fix-line-endings.ps1 # Line ending normalization
β βββ fix-production.bat # Production fix utilities
β βββ format-code.ps1 # Code formatting scripts
β βββ run-tests.bat # Test execution scripts
β βββ start-test.bat # Test environment setup
β βββ README.md # Scripts documentation
βββ wiki/ # Comprehensive documentation
βββ __tests__/ # Test suites
β βββ integration/ # Integration tests
β βββ unit/ # Unit tests
β βββ utils/ # Test utilities
βββ __mocks__/ # Test mocks
βββ coverage/ # Code coverage reports
βββ test-results/ # Test result outputs
βββ logs/ # Application logs
βββ .qlty/ # Code quality configuration
β βββ qlty.toml # Main qlty configuration
β βββ configs/ # Tool-specific configurations
βββ .github/ # GitHub configuration
βββ .cursor/ # Cursor IDE configuration
βββ package.json # Project metadata
βββ ecosystem.config.js # PM2 deployment config
βββ jest.config.js # Jest test configuration
βββ jest.setup.js # Jest setup file
βββ .prettierrc # Prettier configuration
βββ .eslintrc.json # ESLint configuration
βββ .env.example # Environment variables example
βββ SECURITY.md # Security policy and guidelines
βββ CONTRIBUTING.md # Contribution guidelines
βββ CODE_OF_CONDUCT.md # Community code of conduct
βββ CHANGELOG.md # Project changelog
βββ LICENSE # License file
βββ .env # Environment secrets (not committed)
This project maintains high code quality standards using qlty for unified linting, formatting, security scanning, and maintainability analysis.
- Test Coverage: 1,708+ tests passing β dual thresholds: β₯80% critical files / β₯65% global baseline
- Code Quality: 94.8% reduction in ESLint issues with systematic complexity reduction
- Security: Zero tolerance for secrets, timing-safe authentication, vulnerability scanning
- Code Complexity: Max 15 complexity per file, 10 per function
- Formatting: Consistent code style with Prettier
npm run quality:check # Quick quality check
npm run quality:fix # Auto-fix formatting and linting
npm run quality:metrics # View code metrics and complexity
npm run quality:smells # Detect code smells and duplication
npm run security:all # Full security scanningFor detailed information, see docs/qlty/README.md.
npm test # Run all tests
npm run coverage # Run tests with coverage report
npm run test:branch-coverage # Run branch coverage testsThe test suite includes:
- Unit tests for all service modules
- Integration tests for bot functionality
- Database integration tests
- Branch coverage tests for critical components
For detailed testing information, see Testing Guide.
Live coverage metrics are maintained in docs/COVERAGE-STATUS.md.
The project uses GitHub Actions for continuous integration and deployment. The pipeline:
- Builds the application
- Runs all tests with coverage reporting
- Performs security checks using npm audit
- Uploads coverage data to Codecov and QLTY
- Prepares for deployment when merging to main branch
View the CI/CD workflow in .github/workflows/unified-ci.yml
- Double-check your
DISCORD_BOT_TOKENin.env - Confirm the token has not been regenerated or revoked
- Ensure your bot has permission to join and read messages in your server
- Validate your API key is current and supports the
chat/completionsendpoint - Ensure model name is
"sonar"and the format of your payload is correct - Test the same key using a tool like Postman or curl
- Add clickable sources and reference links from Perplexity results
- Enhance error handling with retry/backoff logic for API rate limits
- Implement AI-powered content moderation for safer interactions
Pull requests and ideas are always welcome! Please:
- Fork the repository
- Create a new branch
- Submit a PR with your changes
Source Available - All Rights Reserved
- β View & Learn β You can read, study, and learn from this code
- β No Copying β You cannot clone, fork, or download this repository
- β No Use β You cannot use this code in your own projects
- β No Distribution β You cannot share or redistribute this code
- β No Running β You cannot deploy or run this software
All uses beyond viewing require explicit written permission. To request permission:
- Open an issue on GitHub
- Describe your intended use
- Wait for approval from the copyright holder
Permission is granted at my sole discretion.
Made for the Aszune community. Powered by Discord, Perplexity, and Node.js.
See CHANGELOG.md for full version history.
For detailed release notes: