Skip to content

Debug Tools

Gamer100309 edited this page Dec 25, 2025 · 1 revision

🐛 Debug Tools

Comprehensive testing and diagnostic utilities for the bot.


📋 Overview

The bot includes 30+ debug tools for testing, validation, and troubleshooting.

Location: Mc Server Stats Bot/Debug/


🚀 Quick Start

Run All Tests

Windows:

Test_all_debug_tools.bat

Linux/Mac:

chmod +x Test_all_debug_tools.sh
./Test_all_debug_tools.sh

Run Individual Test

node Debug/token-validator.js
node Debug/network-test.js
node Debug/config-validator.js

🔧 Validation Tools

token-validator.js

Purpose: Validate Discord bot token

Usage:

node Debug/token-validator.js

Checks:

  • ✅ 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

config-validator.js

Purpose: Validate configuration files

Usage:

node Debug/config-validator.js

Checks:

  • ✅ 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

language-validator.js

Purpose: Validate language files

Usage:

node Debug/language-validator.js

Checks:

  • ✅ 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

🌐 Network Tools

network-test.js

Purpose: Test network connectivity

Usage:

node Debug/network-test.js

Tests:

  • ✅ 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

status-simulator.js

Purpose: Simulate server status responses

Usage:

node Debug/status-simulator.js

Simulates:

  • Online server
  • Offline server
  • Timeout
  • Invalid response

Use for: Testing without actual Minecraft server


🎮 Command Tools

command-tester.js

Purpose: Test bot commands

Usage:

node Debug/command-tester.js

Tests:

  • /setup command registration
  • /reload functionality
  • /refresh execution
  • /botinfo response
  • /checkperms validation

Output:

Testing /setup command...
✅ Command registered
✅ Permissions correct

Testing /botinfo...
✅ Response generated
✅ All data present

emoji-tester.js

Purpose: Test emoji rendering

Usage:

node Debug/emoji-tester.js

Tests:

  • Standard emojis
  • Custom emojis
  • Emoji IDs
  • Fallback behavior

📊 Analysis Tools

error-analyzer.js

Purpose: Analyze error logs

Usage:

node Debug/error-analyzer.js

Analyzes:

  • 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

performance-monitor.js

Purpose: Monitor bot performance

Usage:

node Debug/performance-monitor.js

Monitors:

  • 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

state-analyzer.js

Purpose: Analyze bot state

Usage:

node Debug/state-analyzer.js

Shows:

  • Active guilds
  • Monitored servers
  • Active monitoring sessions
  • Message cache

🔍 Inspection Tools

guild-reporter.js

Purpose: Generate guild report

Usage:

node Debug/guild-reporter.js

Reports:

  • 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

message-preview.js

Purpose: Preview status messages

Usage:

node Debug/message-preview.js

Shows:

  • How embeds will look
  • Color coding
  • Formatting
  • Icon display

🛠️ Utility Tools

fix-syntax.js

Purpose: Fix common JSON syntax errors

Usage:

node Debug/fix-syntax.js configs/123456789.json

Fixes:

  • 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.

export-report.js

Purpose: Export debug report

Usage:

node Debug/export-report.js

Exports:

  • System information
  • Bot configuration
  • Error logs
  • Performance data

Output: debug-report-2025-12-25.json


health-monitor.js

Purpose: Overall health check

Usage:

node Debug/health-monitor.js

Checks:

  • 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

🔄 State Management Tools

state-cleanup.js

Purpose: Clean up bot state

Usage:

node Debug/state-cleanup.js

Cleans:

  • Orphaned messages
  • Invalid configurations
  • Old cache data
  • Stale monitoring sessions

backup-manager.js

Purpose: Backup configurations

Usage:

node Debug/backup-manager.js

Creates backup:

backups/
├── global-config-2025-12-25.json
└── configs-2025-12-25/
    ├── 123456789.json
    └── 987654321.json

📝 File Checking Tools

check-files.js

Purpose: Verify all required files exist

Usage:

node Debug/check-files.js

Checks:

  • Core files (index.js, package.json)
  • Class files
  • Language files
  • Config files

check-dependencies.js

Purpose: Verify npm dependencies

Usage:

node Debug/check-dependencies.js

Checks:

  • All dependencies installed
  • Versions correct
  • No vulnerabilities
  • Updates available

🎯 Testing Workflows

Quick Health Check

node Debug/health-monitor.js
node Debug/config-validator.js
node Debug/token-validator.js

Before Deployment

node Debug/check-dependencies.js
node Debug/config-validator.js
node Debug/language-validator.js
node Debug/network-test.js

Troubleshooting

node Debug/error-analyzer.js
node Debug/state-analyzer.js
node Debug/performance-monitor.js

After Updates

./Test_all_debug_tools.sh
node Debug/health-monitor.js

📊 Creating Reports

Full Debug Report

# Run all tests
./Test_all_debug_tools.sh > debug-output.txt

# Generate report
node Debug/export-report.js

# Analyze errors
node Debug/error-analyzer.js

Share with maintainers when reporting bugs!


🔧 Custom Debug Tools

Creating Your Own

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.js

💡 Debug Tips

Enable Verbose Logging

Edit code to add detailed logs:

console.log('[DEBUG] Variable value:', myVar);
console.log('[DEBUG] Function called with:', args);

Use Debugger

Add breakpoints in VS Code or use:

debugger; // Pauses execution

Monitor Live

Use performance-monitor.js while bot runs:

# Terminal 1
node index.js

# Terminal 2
watch -n 5 'node Debug/performance-monitor.js'

🔗 Related Pages


← Back to Home

Clone this wiki locally