diff --git a/core/economy.py b/core/economy.py index 58a86fd..4bfc670 100644 --- a/core/economy.py +++ b/core/economy.py @@ -690,18 +690,19 @@ async def do_season_reset(top_n: int = 10) -> list[tuple[str, int, int]]: # Internal write helper # --------------------------------------------------------------------------- async def _commit(user_id: int, user: UserData) -> None: + record_id = user.get("_pb_id") # type: ignore[typeddict-item] + clean = {k: v for k, v in user.items() if k != "_pb_id"} + clean["user_id"] = str(user_id) try: - record_id = user.get("_pb_id") # type: ignore[typeddict-item] - clean = {k: v for k, v in user.items() if k != "_pb_id"} - clean["user_id"] = str(user_id) if record_id: await pb_client.update_record(record_id, clean) else: _log.warning("_commit for user %s had no _pb_id; creating new record", user_id) created = await pb_client.create_record(clean) user["_pb_id"] = created["id"] # type: ignore[typeddict-unknown-key] - except Exception as exc: + except (aiohttp.ClientError, asyncio.TimeoutError, RuntimeError) as exc: _log.error("_commit failed for user %s: %s", user_id, exc) + raise DatabaseError(f"Failed to persist user {user_id}: {exc}") from exc # --------------------------------------------------------------------------- @@ -952,9 +953,13 @@ async def do_fish_sell(user_id: int, indices: list[int] | None = None) -> dict: to_sell = inv remaining = [] else: - valid_indices = [i if i >= 0 else len(inv) + i for i in indices] - to_sell = [inv[i] for i in sorted(set(valid_indices)) if 0 <= i < len(inv)] - keep_idx = set(range(len(inv))) - set(indices) + sell_idx = { + (i if i >= 0 else len(inv) + i) + for i in indices + } + sell_idx = {i for i in sell_idx if 0 <= i < len(inv)} + to_sell = [inv[i] for i in sorted(sell_idx)] + keep_idx = set(range(len(inv))) - sell_idx remaining = [inv[i] for i in sorted(keep_idx)] if not to_sell: diff --git a/docs/PATCHNOTES.md b/docs/PATCHNOTES.md index c454d8d..6f87d89 100644 --- a/docs/PATCHNOTES.md +++ b/docs/PATCHNOTES.md @@ -1,8 +1,10 @@ -# TipiBOTi muudatuste logi +# TipiBOT changelog -Siit leiad ülevaate TipiBOTi uuendustest. Uusimad muudatused on üleval. -Vorminda iga versioon `## ` peakirjaga (nt `## v0.1.0 — 2026-05-03`). +Here you'll find an overview of TipiBOT updates. Latest changes are at the top. +Format each version with a `## ` header (e.g. `## v0.1.0 — 2026-05-03`). ## v0.1.0 — 2026-05-03 -- Lisatud `/patchnotes` +- Added `/patchnotes` +- Fixed silent swallowing of database write errors — failed saves now show the user an error instead of appearing to succeed +- Fixed fish-sell bug that let the last fish be duplicated (sold and kept in inventory)