- Create .env.example for environment variable setup - Add .gitignore to exclude sensitive files and cache - Implement README.md with setup instructions and usage details - Develop main.py for fetching and posting player stats to Discord - Create overlay.py for displaying stats in a GUI overlay - Add players.json to define players to track - Specify dependencies in requirements.txt
2.0 KiB
2.0 KiB
Stats Tracker 📊
A Python script that tracks Minecraft server player stats and posts them to Discord via webhook.
Setup
1. Install Dependencies
pip install -r requirements.txt
2. Configure Environment Variables
Copy the example file and fill in your credentials:
cp .env.example .env
Edit .env and add:
DISCORD_WEBHOOK_URL: Your Discord webhook URLAPI_KEY: Your DonutSMP API key (get it with/apiin-game)
3. Add Players to Track
Edit players.json and add the usernames you want to track:
{
"players": ["player1", "player2", "player3"]
}
Running
python main.py
The script will:
- ✅ Fetch stats every 2 minutes
- ✅ Create a new Discord message on first run
- ✅ Edit the same message on subsequent updates (no spam!)
- ✅ Only update the message if stats actually change (saves API calls)
- ✅ Display stats grouped by type across all players
- ✅ Show: Money, Playtime, Kills, Deaths, Mobs Killed, Blocks Placed/Broken, Shards
How It Works
- First Run: Posts a new message with all player stats grouped by type
- Subsequent Runs:
- Compares current stats with cached stats
- Only edits the Discord message if something changed
- Skips updates if stats are unchanged (saves Discord API calls)
- No Message Found: If
message_id.txtis deleted or the Discord message is removed, it will create a new one - Error Handling: If a player doesn't exist or API fails, it shows "❌" for that player
Files Created
message_id.txt- Stores the Discord message ID for editsstats_cache.json- Caches previous stats to detect changes
Notes
- The message ID is automatically saved to prevent creating duplicate messages
- Stats are cached to avoid unnecessary Discord updates
- If you want to reset and create a new message, delete
message_id.txtandstats_cache.json - The script handles network errors gracefully and will retry every 2 minutes
- Press
Ctrl+Cto stop the script