Fix /player autocomplete timeout by using current season only
All checks were successful
Build Docker Image / build (pull_request) Successful in 57s

The all_seasons=True parameter causes the API search query to take 15+ seconds,
exceeding Discord's 3-second autocomplete timeout. Changed to all_seasons=False
to search only the current season, which is fast enough.

Users can still access historical players by manually typing the name and using
the season parameter in the /player command.

Fixes: discord.errors.NotFound 404 (error code: 10062): Unknown interaction

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-02-05 20:44:47 -06:00
parent 0bc1ebc354
commit 42b9fa5df2

View File

@ -31,12 +31,13 @@ async def player_name_autocomplete(
return []
try:
# Use the dedicated search endpoint to get matching players across ALL seasons
# Use the dedicated search endpoint to get matching players
# Search current season only for performance (all_seasons=True takes 15+ seconds)
# Results are ordered by most recent season first
players = await player_service.search_players(
current,
limit=50,
all_seasons=True, # Fetch more to ensure 25 unique names
limit=30,
all_seasons=False, # Current season only to stay under 3-second timeout
)
# Deduplicate by player name, keeping only the first (most recent) occurrence