From db15993b021ba33c7d3f219d7f5a84882b8f0976 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 9 Mar 2026 13:25:44 -0500 Subject: [PATCH] fix: handle db_patch failure in buy scout token flow 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 --- discord_ui/scout_view.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/discord_ui/scout_view.py b/discord_ui/scout_view.py index 277b275..9617c9d 100644 --- a/discord_ui/scout_view.py +++ b/discord_ui/scout_view.py @@ -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