Skip to content

Fix scammer-report flow: interaction-failed buttons and lost roles on release#39

Merged
HiLleywyn merged 2 commits into
mainfrom
claude/fix-report-button-interaction-failed
Jun 4, 2026
Merged

Fix scammer-report flow: interaction-failed buttons and lost roles on release#39
HiLleywyn merged 2 commits into
mainfrom
claude/fix-report-button-interaction-failed

Conversation

@HiLleywyn
Copy link
Copy Markdown
Owner

@HiLleywyn HiLleywyn commented Jun 4, 2026

Two bug fixes for the scammer-report / containment flow, both surfaced while testing the report buttons.

1. "This interaction failed" on the report buttons

The Clank, False report (30m), and dehoist-alert Clank buttons ran the full containment path (warden_contain → role edits, DB, purge, escape-room setup) before acknowledging the interaction. Discord requires acknowledgement within ~3s; when containment took longer the token expired, the reply 404'd, and the click showed "This interaction failed" with no action taken.

Fix: defer() immediately, then do the work and reply via followup (edit_original_response for the in-place alert). Failures now surface the real reason (immunity / role hierarchy) instead of a generic message. (cogs/dehoist.py)

2. Roles not restored on unclank

Releasing a clanked user sometimes handed back none of their roles. Two causes:

  • Re-clank wiped the saved roles. Clanking someone already in the tank hit INSERT ... ON CONFLICT DO UPDATE with stored_roles = current roles — but a contained user only wears the Clanker role, so the original roles were overwritten with an empty set and lost. The conflict path now preserves the existing non-empty stored_roles.
  • Restore was all-or-nothing. add_roles(*all_saved) is a single atomic call; one managed role (booster/bot/integration) or a role above the bot's top role made Discord reject the whole batch. Restore now filters to assignable roles and falls back to per-role adds so one un-assignable role can't block the rest. Un-restorable roles are logged. (cogs/clank.py)

py_compile clean for both files; the SQL CASE is standard Postgres (references the existing row via the table name in ON CONFLICT DO UPDATE). These are integration paths exercised against a live Discord guild.

Follow-up to #38.

Lleywyn added 2 commits June 4, 2026 19:38
The Clank / False report (30m) buttons on the scam report alert (and the
dehoist alert's Clank button) ran the full containment path before
acknowledging the interaction. When warden_contain took longer than
Discord's 3-second interaction window, the token expired, the reply 404'd,
and the click surfaced "This interaction failed".

Defer the interaction up front and reply via followup (edit_original_response
for the in-place alert update). Also surface the real reason -- e.g. an
immune target or role-hierarchy problem -- instead of a generic failure.
Two distinct bugs left a released clanker without their old roles:

1. Re-clanking a user already in the tank ran the INSERT ... ON CONFLICT
   DO UPDATE with stored_roles = current roles -- but a contained user only
   wears the Clanker role, so the original roles were overwritten with an
   empty set and lost forever. Preserve the existing non-empty stored_roles
   on conflict instead.

2. Restoration used a single atomic add_roles(*all): if any saved role was
   managed (booster/bot/integration) or above the bot's top role, Discord
   rejected the whole call and nothing was restored. Filter to assignable
   roles and fall back to per-role adds so one bad role can't block the rest.
@HiLleywyn HiLleywyn changed the title Fix "This interaction failed" on scammer-report buttons Fix scammer-report flow: interaction-failed buttons and lost roles on release Jun 4, 2026
@HiLleywyn HiLleywyn merged commit cc3e19c into main Jun 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants