fix: handle db_patch failure in buy scout token flow
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m20s

Wrap the wallet deduction in try/except so a failed db_patch immediately
stops the view and shows an error, instead of leaving it open for 30s.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-09 13:25:44 -05:00
parent a509a4ebf5
commit db15993b02

View File

@ -339,7 +339,18 @@ class BuyScoutTokenView(discord.ui.View):
# Deduct currency
new_wallet = team["wallet"] - SCOUT_TOKEN_COST
await db_patch("teams", object_id=team["id"], params=[("wallet", new_wallet)])
try:
await db_patch(
"teams", object_id=team["id"], params=[("wallet", new_wallet)]
)
except Exception as e:
logger.error(f"Failed to deduct scout token cost: {e}")
await interaction.response.edit_message(
content="Something went wrong processing your purchase. Try again!",
view=None,
)
self.stop()
return
self.scouter_team = team
self.scouter_team["wallet"] = new_wallet