I've expanded your rank-fetch scraper into a complete Discord bot for managing alliance ranks in your STFC server. The bot:
✅ Fetches player data including Premier rank support (newly added)
✅ Verifies players are on your specific STFC server
✅ Sets nicknames to [TAG] username format
✅ Assigns roles based on alliance rank with smart confirmation logic
✅ Detects daily rank changes and requests admin confirmation
✅ Stores verification screenshots for record-keeping
| File | Purpose |
|---|---|
stfc_scraper.py |
Updated to support Premier rank |
bot.py |
Complete Discord bot implementation |
requirements.txt |
Python dependencies |
.env.example |
Configuration template |
README.md |
Updated with bot documentation |
cd STFC-Verifier
cp .env.example .env
nano .env # Edit with your valuesRequired values:
DISCORD_TOKEN- Get from Discord Developer PortalGUILD_ID- Right-click your server, "Copy Server ID"STFC_SERVER_ID- Your STFC server (e.g., 118, 106)MEMBER_ROLE_ID,COMMODORE_ROLE_ID,ADMIRAL_ROLE_ID,ADMIN_ROLE_IDVERIFY_CHANNEL_ID- Where users run /verifyLOG_CHANNEL_ID- Where rank confirmations are posted
Create these roles in your Discord server (exact names matter for Discord):
- Member (or similar for base role)
- Commodore
- Admiral
- Admin (or similar for admins)
Get their IDs by right-clicking → Copy Role ID
- A #verification channel (where users run /verify)
- A #rank-confirmations channel (where admin confirms ranks)
- Go to Discord Developer Portal
- Create New Application
- Go to Bot section, click Add Bot
- Copy the TOKEN to
.envasDISCORD_TOKEN - Go to OAuth2 → URL Generator
- Select scopes:
bot,applications.commands - Select permissions:
Send Messages,Manage Nicknames,Manage Roles,Read Message History - Copy generated URL and use to invite bot to your server
cd ~/rank-fetch
source venv/bin/activate
python3 bot.py- User runs
/verifycommand - User provides: STFC player URL/ID (e.g.,
https://stfc.pro/players/2659122580) - User uploads screenshot of their player profile
- Bot verifies they're on the correct STFC server
- Bot sets their nickname to
[TAG] username(e.g.,[SITH] DarthHαywire) - Base ranks (Agent/Operative/Premier): Role assigned immediately ✓
- Leadership ranks (Commodore/Admiral): Admin gets confirmation message in log channel with Accept/Reject buttons
- Bot checks all verified players every 24 hours (configurable)
- If any rank change detected (up or down):
- Bot posts confirmation request to log channel
- Admin can Accept (apply new rank) or Reject (keep old rank)
- User's nickname updates automatically if name changed
| Rank | Tier | Role Assignment | Confirmation Needed |
|---|---|---|---|
| Agent | Base | Immediate | ❌ No |
| Operative | Base | Immediate | ❌ No |
| Premier | Base | Immediate | ❌ No |
| Commodore | Leadership | After Admin Approval | ✅ Yes |
| Admiral | Leadership | After Admin Approval | ✅ Yes |
/verify <player_url_or_id> <screenshot>
- Verify your STFC player account
player_url_or_id: Your stfc.pro/stfc.wtf URL or player IDscreenshot: Screenshot of your player profile (for logging)
Example:
/verify https://stfc.pro/players/2659122580 [upload screenshot]
When a rank change (initial verification or daily update) needs confirmation, you'll see:
- Blue log message showing player verification with screenshot
- Orange message with Accept/Reject buttons for rank confirmation
Click the buttons to approve or deny the rank change.
Player data is stored in stfc_players.db:
- Discord user ID
- STFC player ID and username
- Server ID and level
- Alliance tag and rank
- Screenshot URL
Data is automatically backed up on each verification/update.
DISCORD_TOKEN=<your_bot_token>
GUILD_ID=<server_id>
STFC_SERVER_ID=<stfc_server_id>
VERIFY_CHANNEL_ID=<verification_channel_id>
LOG_CHANNEL_ID=<log_channel_id>
MEMBER_ROLE_ID=<base_role_id>
COMMODORE_ROLE_ID=<commodore_role_id>
ADMIRAL_ROLE_ID=<admiral_role_id>
ADMIN_ROLE_ID=<admin_role_id>
UPDATE_CHECK_HOURS=24 # Daily updates
DB_PATH=stfc_players.db
DEBUG=0 # Set to 1 for verbose logging
Bot doesn't respond to /verify?
- Make sure bot has permission to use slash commands
- Check if bot is in the server (with proper permissions)
- Verify
VERIFY_CHANNEL_IDis set correctly
Can't update nicknames?
- Bot role must be ABOVE the roles it manages in Discord role hierarchy
- Give bot "Manage Nicknames" permission
Confirmation messages not appearing?
- Check
LOG_CHANNEL_IDis correct and bot can post there - Verify
ADMIN_ROLE_IDis set (or empty to disable pinging)
Player data not fetching?
- Verify
STFC_SERVER_IDmatches the player's server - Make sure player URL/ID is valid
- Check internet connection to stfc.pro
The bot is built to be extensible. You can:
- Change update frequency by setting
UPDATE_CHECK_HOURS - Add more rank tiers by modifying
RANK_TIERSinbot.py - Add more confirmation logic in
_assign_ranks()method - Customize embed messages and colors