-
Notifications
You must be signed in to change notification settings - Fork 0
Debug Tools
Comprehensive testing and diagnostic utilities for the bot.
The bot includes 30+ debug tools for testing, validation, and troubleshooting.
Location: Mc Server Stats Bot/Debug/
Windows:
Test_all_debug_tools.batLinux/Mac:
chmod +x Test_all_debug_tools.sh
./Test_all_debug_tools.shnode Debug/token-validator.js
node Debug/network-test.js
node Debug/config-validator.jsPurpose: Validate Discord bot token
Usage:
node Debug/token-validator.jsChecks:
- ✅ Token exists in config
- ✅ Token format is valid
- ✅ Token length correct
- ✅ Token can authenticate
Output:
✅ Token found in config
✅ Token format valid
✅ Token length: 72 characters
✅ Authentication successful
Purpose: Validate configuration files
Usage:
node Debug/config-validator.jsChecks:
- ✅ JSON syntax valid
- ✅ Required fields present
- ✅ Data types correct
- ✅ Values within valid ranges
Output:
Checking global-config.json...
✅ JSON syntax valid
✅ Token present
✅ Language valid: en
Checking guild configs...
✅ configs/123456789.json valid
Purpose: Validate language files
Usage:
node Debug/language-validator.jsChecks:
- ✅ All language files exist
- ✅ JSON syntax valid
- ✅ All keys from en.json present
- ✅ No missing translations
Output:
Validating en.json...
✅ 87 keys found
Validating de.json...
✅ All keys present
✅ No missing translations
Purpose: Test network connectivity
Usage:
node Debug/network-test.jsTests:
- ✅ Internet connectivity
- ✅ Discord API reachable
- ✅ DNS resolution
- ✅ Minecraft server queries
Output:
Testing internet connectivity...
✅ Internet connection OK
Testing Discord API...
✅ Discord API reachable (45ms)
Testing DNS resolution...
✅ DNS working correctly
Purpose: Simulate server status responses
Usage:
node Debug/status-simulator.jsSimulates:
- Online server
- Offline server
- Timeout
- Invalid response
Use for: Testing without actual Minecraft server
Purpose: Test bot commands
Usage:
node Debug/command-tester.jsTests:
-
/setupcommand registration -
/reloadfunctionality -
/refreshexecution -
/botinforesponse -
/checkpermsvalidation
Output:
Testing /setup command...
✅ Command registered
✅ Permissions correct
Testing /botinfo...
✅ Response generated
✅ All data present
Purpose: Test emoji rendering
Usage:
node Debug/emoji-tester.jsTests:
- Standard emojis
- Custom emojis
- Emoji IDs
- Fallback behavior
Purpose: Analyze error logs
Usage:
node Debug/error-analyzer.jsAnalyzes:
- Error frequency
- Error types
- Common patterns
- Suggested fixes
Output:
Analyzing error logs...
Most common errors:
1. ECONNREFUSED (15 occurrences)
2. Timeout (8 occurrences)
3. Invalid config (3 occurrences)
Suggestions:
- Check server IP configuration
- Increase timeout value
Purpose: Monitor bot performance
Usage:
node Debug/performance-monitor.jsMonitors:
- Memory usage
- CPU usage
- Response times
- Query performance
Output:
Performance Report:
Memory: 145 MB
CPU: 2.3%
Avg Response Time: 1.2s
Queries/min: 12
Purpose: Analyze bot state
Usage:
node Debug/state-analyzer.jsShows:
- Active guilds
- Monitored servers
- Active monitoring sessions
- Message cache
Purpose: Generate guild report
Usage:
node Debug/guild-reporter.jsReports:
- Guild count
- Server configurations
- Channel assignments
- Permission status
Output:
Guild Report
Total Guilds: 5
Total Servers Monitored: 12
Guild: My Server (ID: 123456789)
├── Servers: 3
├── Channels: 2
└── Status: Active
Purpose: Preview status messages
Usage:
node Debug/message-preview.jsShows:
- How embeds will look
- Color coding
- Formatting
- Icon display
Purpose: Fix common JSON syntax errors
Usage:
node Debug/fix-syntax.js configs/123456789.jsonFixes:
- Trailing commas
- Missing quotes
- Incorrect escaping
- Invalid characters
Output:
Checking configs/123456789.json...
❌ Trailing comma found at line 15
✅ Fixed automatically
File validated and saved.
Purpose: Export debug report
Usage:
node Debug/export-report.jsExports:
- System information
- Bot configuration
- Error logs
- Performance data
Output: debug-report-2025-12-25.json
Purpose: Overall health check
Usage:
node Debug/health-monitor.jsChecks:
- Bot is running
- All services operational
- No critical errors
- Resource usage normal
Output:
Health Check Report
✅ Bot Status: Running
✅ Discord Connection: OK
✅ Database: Connected
✅ Memory Usage: Normal (145 MB)
✅ No critical errors
Overall Health: GOOD
Purpose: Clean up bot state
Usage:
node Debug/state-cleanup.jsCleans:
- Orphaned messages
- Invalid configurations
- Old cache data
- Stale monitoring sessions
Purpose: Backup configurations
Usage:
node Debug/backup-manager.jsCreates backup:
backups/
├── global-config-2025-12-25.json
└── configs-2025-12-25/
├── 123456789.json
└── 987654321.json
Purpose: Verify all required files exist
Usage:
node Debug/check-files.jsChecks:
- Core files (index.js, package.json)
- Class files
- Language files
- Config files
Purpose: Verify npm dependencies
Usage:
node Debug/check-dependencies.jsChecks:
- All dependencies installed
- Versions correct
- No vulnerabilities
- Updates available
node Debug/health-monitor.js
node Debug/config-validator.js
node Debug/token-validator.jsnode Debug/check-dependencies.js
node Debug/config-validator.js
node Debug/language-validator.js
node Debug/network-test.jsnode Debug/error-analyzer.js
node Debug/state-analyzer.js
node Debug/performance-monitor.js./Test_all_debug_tools.sh
node Debug/health-monitor.js# Run all tests
./Test_all_debug_tools.sh > debug-output.txt
# Generate report
node Debug/export-report.js
# Analyze errors
node Debug/error-analyzer.jsShare with maintainers when reporting bugs!
Template:
// Debug/my-test.js
const fs = require('fs');
const path = require('path');
console.log('Running my custom test...\n');
try {
// Your test logic here
console.log('✅ Test passed');
} catch (error) {
console.error('❌ Test failed:', error.message);
process.exit(1);
}Run it:
node Debug/my-test.jsEdit code to add detailed logs:
console.log('[DEBUG] Variable value:', myVar);
console.log('[DEBUG] Function called with:', args);Add breakpoints in VS Code or use:
debugger; // Pauses executionUse performance-monitor.js while bot runs:
# Terminal 1
node index.js
# Terminal 2
watch -n 5 'node Debug/performance-monitor.js'- Development Setup - Dev environment
- Troubleshooting - Common issues
- Contributing Code - Code contributions