Skip to content

Fix party buttons returning 'not found' after bot restart#161

Merged
psykzz merged 5 commits into
mainfrom
fix/party-persistent-view-routing
Jun 19, 2026
Merged

Fix party buttons returning 'not found' after bot restart#161
psykzz merged 5 commits into
mainfrom
fix/party-persistent-view-routing

Conversation

@psykzz

@psykzz psykzz commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes a bug where clicking the Sign Up / Leave / Edit / Delete buttons on a party embed returns "Party not found" after a bot restart.

Root Cause

PartyView buttons all share static custom_ids (party_signup, party_leave, party_edit, party_delete). When _register_persistent_views called bot.add_view(view) without a message_id, discord.py could only route each custom_id to a single view — the last one registered. Any party whose view was overwritten in this loop would fail with "party not found" on every button click.

Changes

  • party/party.py_register_persistent_views: pass message_id to bot.add_view() so each view is bound to its specific embed message. Discord.py then routes by (message_id, custom_id) tuple, correctly isolating each party.
  • party/party.py — new [p]party fix <party_id> command (admin/manage_guild): re-renders the embed and re-registers the persistent view for an existing party. Useful for parties created before this fix.

Testing

  • Syntax validated: python -m py_compile party/party.py
  • Manually verified logic: after restart, each view is bound to its own message_id so button routing is isolated per party.
  • [p]party fix command tested path: fetches message, calls add_view(view, message_id=...), edits message with fresh embed + view.

Risk

Low. The change to _register_persistent_views is strictly additive (passing an extra kwarg). The new fix command is additive and gated behind admin_or_permissions(manage_guild=True).

Claude AI and others added 5 commits June 19, 2026 17:48
All PartyView buttons share static custom_ids (party_signup, party_leave,
etc). Without message_id, discord.py routes all button interactions to the
last-registered view, causing 'party not found' for every other party after
a bot restart.

Pass message_id to add_view so each view is tied to its specific message.
Adds [p]party fix <id> (admin only) that:
- Fetches the existing party message
- Re-registers the persistent view bound to that message_id
- Edits the message with a fresh embed + reattached buttons

Useful for existing parties created before the persistent view
routing fix, where buttons were broken after a bot restart.
@psykzz psykzz self-assigned this Jun 19, 2026
@psykzz psykzz merged commit 9efd728 into main Jun 19, 2026
3 checks passed
@psykzz psykzz deleted the fix/party-persistent-view-routing branch June 19, 2026 18:27
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