Skip to content

refactor(party): extract _make_party and _post_party to remove 3x copy-paste#175

Merged
psykzz merged 1 commit into
refactor/party-split-modulesfrom
refactor/party-make-factory
Jun 20, 2026
Merged

refactor(party): extract _make_party and _post_party to remove 3x copy-paste#175
psykzz merged 1 commit into
refactor/party-split-modulesfrom
refactor/party-make-factory

Conversation

@psykzz

@psykzz psykzz commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Closes #167

What

Party dict construction + two-step config write (save → send → update IDs) was copy-pasted in three places. Extracted:

  • _make_party(party_id, name, author_id, roles, ...) — static factory for the dict
  • _post_party(guild, channel, party, party_id) — save to config, send embed+view, update message/channel IDs

All three creation sites now use these helpers.

Validation

  • python -m py_compile party/party.py party/views.py — clean
  • flake8 party/ --select=F821,E9 — clean

…y-paste

Closes #167

Party dict construction and two-step config-write (save -> send -> save IDs)
were duplicated in party_create, party_template_use, and CreatePartyModal.
_make_party builds the dict; _post_party handles save+send+ID update.
@psykzz psykzz merged commit 41e48af into refactor/party-split-modules Jun 20, 2026
3 checks passed
@psykzz psykzz deleted the refactor/party-make-factory branch June 20, 2026 07:47
psykzz added a commit that referenced this pull request Jun 20, 2026
…y-paste (#175)

Closes #167

Party dict construction and two-step config-write (save -> send -> save IDs)
were duplicated in party_create, party_template_use, and CreatePartyModal.
_make_party builds the dict; _post_party handles save+send+ID update.
psykzz added a commit that referenced this pull request Jun 20, 2026
* refactor(party): delete dead EditPartyModal class (#174)

Closes #171

EditPartyModal (title+description only) was superseded by EditPartyFullModal
(all settings). PartyView.edit_button always opens EditPartyFullModal.
No references to EditPartyModal exist outside its own definition.

* refactor(party): extract _make_party and _post_party to remove 3x copy-paste (#175)

Closes #167

Party dict construction and two-step config-write (save -> send -> save IDs)
were duplicated in party_create, party_template_use, and CreatePartyModal.
_make_party builds the dict; _post_party handles save+send+ID update.

* refactor(party): extract has_party_permission to remove 7x copy-paste (#177)

Closes #168

The author/admin permission check was copy-pasted in party_description, party_settime, party_compact, party_rename_option, party_delete, PartyView.edit_button, and PartyView.delete_button. Extracted to has_party_permission() in helpers.py to avoid circular import.

* refactor(party): simplify RoleSelectionModal placeholder truncation (#176)

Closes #172

The 26-line nested conditional block for building a modal placeholder
(with dead suffix variable) is replaced with 5 clear lines.
Behaviour is identical: prefix + truncated roles list at 100 chars.

* refactor(party): extract _reply helper to collapse signup_user branching (#178)

Closes #164

signup_user had a disabled_view+deferred 2x2 matrix repeated for every
response (not-found, role-full, success) = 12 near-duplicate blocks.
Extracted _reply() collapses all paths. signup_user drops ~120->~35 lines.
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.

1 participant