fix: daily check-in interaction migration + paperdex dupe detection #107
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#107
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/checkin-and-paperdex-fixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #19, Fixes #23
Summary
daily_checkinmigration todiscord.Interaction. Removed twogreeting =assignments and replacedawait greeting.edit(...)withawait interaction.edit_original_response(...). Also removed the# TODO: complete the migration to an interactioncomment.get_card_embeds()(helpers/main.py). The commented-out TODO block is replaced with working code that queries the cards API byplayer_id+team_id, then adds a "Dupes" field to the embed showing how many duplicate copies the team owns.Files changed
cogs/economy.py— 4 lines changed indaily_checkinhelpers/main.py— 5 lines replaced inget_card_embedsTest plan
/comeonmanineedthison a 2nd, 4th, or 5th check-in and confirm the bot responds via interaction (nogreetingAttributeError)/comeonmanineedthiswhenroll_for_cardsreturns nothing and confirm the failure message appears correctly🤖 Generated with Claude Code
AI Code Review
Files Reviewed
cogs/economy.py(modified)helpers/main.py(modified)Findings
Correctness
cogs/economy.py— daily_checkin migration (Fix #19): LGTMAll three references to
greetingare correctly eliminated. The twogreeting = await interaction.edit_original_response(...)assignments are stripped to bareawait interaction.edit_original_response(...)calls (lines 562 and 577 in the working file), and the finalawait greeting.edit(...)on the failure path is replaced withawait interaction.edit_original_response(...)(line 602). The TODO comment is removed. The method is fully migrated and should behave correctly withdiscord.Interaction.helpers/main.py— paperdex dupe detection (Fix #23): BUGdb_getcan returnNonewhen the API responds with a non-200 status (seeapi_calls.pylines 103–106 — the defaultnone_okay=Truemeans failures silently returnNone). The new code does not guard against this:If the cards API call fails,
team_dexwill beNoneandteam_dex['count']raises aTypeError, crashing embed generation for any non-Paper-Dynasty card whenever the API is degraded. A guard is required:There is also a secondary logic issue:
copy_count = team_dex['count'] if team_dex['count'] else 1— if the API returnscount: 0,copy_countis set to1, producing-1 dupes. The original commented-out code had the same flaw. Considerdupe_count = max(0, (team_dex['count'] or 1) - 1)or skip the field entirely when count is 0.Security
No issues found.
Style & Conventions
No issues found. The new code follows the existing patterns in
helpers/main.py— same quoting style, samedb_getcall pattern, same embed field API. The field nameDupes(vs the old commented# Dupes) is correct.Suggestions
copy_countdefault-to-1 fallback when count is 0 is semantically wrong — -1 dupes is nonsensical. Usemax(0, ...)or skip the field when count is 0.Verdict: REQUEST_CHANGES
The
economy.pymigration is clean and correct. Thehelpers/main.pychange has a real crash bug:db_getreturnsNoneon API errors (the defaultnone_okay=Truebehavior), and the new code accessesteam_dex['count']without a None check. On any API degradation, embed generation for all non-Paper-Dynasty cards will throw aTypeError. Please add anif team_dex is not None:guard around the dupe block before merging.Automated review by Claude PR Reviewer
@ -187,2 +184,2 @@# count = 1 if not team_dex['count'] else team_dex['count']# embed.add_field(name='# Dupes', value=f'{count - 1} dupe{"s" if count - 1 != 1 else ""}')if card['team']['lname'] != 'Paper Dynasty':team_dex = await db_get('cards', params=[("player_id", card["player"]["player_id"]), ('team_id', card['team']['id'])])db_getdefaults tonone_okay=True, meaning it returnsNoneon any non-200 API response.team_dex['count']on the next line will raise aTypeErrorif the cards API is unavailable or returns an error. Wrap this block inif team_dex is not None:to prevent crashing embed generation for all non-Paper-Dynasty cards.AI Code Review (Re-review after fix)
Verdict: APPROVED — Gitea blocks self-approval, so this is posted as a COMMENT, but the verdict is a clean approve.
Files Reviewed
helpers/main.py(modified — dupe detection block)cogs/economy.py(modified — daily check-in migration)Findings
Correctness
None guard (helpers/main.py): The previous crash path is correctly closed.
db_getreturningNonenow skips the entire dupe block —if team_dex is not None:wraps both thedupe_countcalculation and theembed.add_fieldcall. No crash can occur.Dupe count math (helpers/main.py):
max(0, team_dex["count"] - 1)is correct for all boundary cases:count = 0→max(0, -1)= 0 dupes (handled safely)count = 1→max(0, 0)= 0 dupes (you own the only copy, correct)count = 2→ 1 dupe (correct)daily_checkin fix (cogs/economy.py): Verified on the branch directly. Both
greeting =assignments are removed, the danglingawait greeting.edit(...)is replaced withawait interaction.edit_original_response(...), and the TODO comment is gone. No reference togreetingremains in this function.Security
No issues found.
Style & Conventions
No issues found. The new block uses consistent double-quote strings and matches surrounding code style.
Suggestions
if team_dex is not None:guard silently omits the "Dupes" field whendb_getreturnsNone. This is reasonable behavior — a missing field beats a crash — but a log line here would help diagnose unexpectedNonereturns in production. Minor; does not block merging.Summary
Both reported issues are correctly fixed. The None guard closes the crash path cleanly, the dupe count math is correct at all boundary values, and the economy.py interaction migration is fully applied with no remaining
greetingreferences. No new issues introduced.Automated review by Claude PR Reviewer
ee01fce0b8to1c03d91478