CLAUDE: Fix get_roster_sheet() to handle both dict and Team objects

Fixed TypeError: 'Team' object is not subscriptable error occurring at the
end of /gauntlet start command when sending completion messages.

The get_roster_sheet() function was using dict syntax (team["gsheet"]) but
was receiving Team objects from gauntlet commands. Updated the function to
handle both dict and Team object formats using isinstance() check.

This follows the same pattern as get_context_user() and owner_only() for
handling multiple input types gracefully.

Fixes: Command 'start' raised an exception: TypeError: 'Team' object is
not subscriptable (reported at end of gauntlet draft completion)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-11-10 09:11:37 -06:00
parent 943dcc9b74
commit c2bbf94925
2 changed files with 16 additions and 4 deletions

View File

@ -77,8 +77,14 @@ def get_roster_sheet_legacy(team):
def get_roster_sheet(team): def get_roster_sheet(team):
"""Get roster sheet URL for a team.""" """
return f'https://docs.google.com/spreadsheets/d/{team["gsheet"]}/edit' Get roster sheet URL for a team.
Handles both dict and Team object formats.
"""
# Handle both dict (team["gsheet"]) and object (team.gsheet) formats
gsheet = team.get("gsheet") if isinstance(team, dict) else getattr(team, "gsheet", None)
return f'https://docs.google.com/spreadsheets/d/{gsheet}/edit'
def get_player_url(team, player) -> str: def get_player_url(team, player) -> str:

View File

@ -74,8 +74,14 @@ def get_roster_sheet_legacy(team):
def get_roster_sheet(team): def get_roster_sheet(team):
"""Get roster sheet URL for a team.""" """
return f'https://docs.google.com/spreadsheets/d/{team["gsheet"]}/edit' Get roster sheet URL for a team.
Handles both dict and Team object formats.
"""
# Handle both dict (team["gsheet"]) and object (team.gsheet) formats
gsheet = team.get("gsheet") if isinstance(team, dict) else getattr(team, "gsheet", None)
return f'https://docs.google.com/spreadsheets/d/{gsheet}/edit'
def get_player_url(team, player) -> str: def get_player_url(team, player) -> str: