Add initial implementation of Stats Tracker with environment configuration and player stats tracking
Add initial implementation of Stats Tracker with environment configuration and player stats tracking
Add initial implementation of Stats Tracker with environment configuration and player stats tracking
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
- ✅ Detect who is currently online using the lookup API
- ✅ Show online location state icons per player
- ✅ 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
Online Detection Icons
The tracker uses https://api.donutsmp.net/v1/lookup/<username> to detect online state and location:
:sleeping:=Limbo(AFK):yellow_circle:=Spawn:green_circle:=Overworld(also used forNetherandEnd):black_circle:= Offline
Description
Languages
Python
100%