feat(members): assign team roles from the tournament registration sheet

Match members by Discord username against the lineup nicknames in the
separate registration spreadsheet (TEAM_SHEET_ID) and give each their
team's role. One team per person: switching teams removes the old team
role, and a team with no Discord role yet is auto-created. Only role
names present in the sheet are ever touched, so organisation/field/base
roles are never at risk; the feature is a no-op when TEAM_SHEET_ID is
unset.

The sheet is not a single table (merged rows, stacked CS2/LoL sections
with different layouts), so it is parsed via raw-row scanning rather than
get_all_records. Citizenship markers like "(EST)" are used only as
player delimiters and discarded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rene Arumetsa
2026-08-28 14:01:22 +03:00
parent 567a82b9f2
commit 52002c37fc
7 changed files with 438 additions and 1 deletions

6
bot.py
View File

@@ -420,6 +420,12 @@ async def on_ready():
log.info("Loaded %d member rows from Google Sheets", len(data))
except Exception as e:
log.error("Failed to load sheet on startup: %s", e)
try:
rosters = await sheets.refresh_teams()
if rosters:
log.info("Loaded %d teams from the registration sheet", len(rosters))
except Exception as e:
log.error("Failed to load team sheet on startup: %s", e)
# Sync slash commands to the guild only; wipe any leftover global registrations
tree.copy_global_to(guild=GUILD_OBJ)