Skip to content

Conversation

@Damego
Copy link
Member

@Damego Damego commented Jan 24, 2023

About

There is known bug (or we just don't support this feature) when you can't edit message from the modal interaction.
This pr fixes this bug by:

  • Moving ComponentContext.defer to _Context.defer and removing CommandContext.defer. They are same but ComponentContext have edit_origin param. So now we can defer with edit_origin for modal.
  • Refactored CommandContext.edit to make work with modals. Code partially copied from ComponentContext.edit.

Additionally:

  • raises exceptions in some places.
  • Use with suppress(LibraryException) instead of this cursed code:
try:
    ...
except LibraryException:
    pass
else:
    ...
  • Optimized conditions in return statements:
# instead of
return msg if msg is not None else Message(...)
# use
return msg or Message(...)

Checklist

  • The pre-commit code linter has been run over all edited files to ensure the code is linted.
  • I've ensured the change(s) work on 3.8.6 and higher.
  • I have added the versionadded, versionchanged and deprecated to any new or changed user-facing function I committed.

Pull-Request specification

I've made this pull request: (check all that apply)

  • For the documentation
  • To add a new feature
  • As a general enhancement
  • As a refactor of the library/the library's code
  • To fix an existing bug
  • To resolve #ISSUENUMBER

This is:

  • A breaking change

@Damego Damego added bug Something isn't working enhancement New feature or request labels Jan 24, 2023
@Damego Damego requested a review from FayeDel January 24, 2023 13:36
@Damego Damego changed the title refactor(context): allow edit message from modal refactor(context): allow edit message from modal interaction Jan 24, 2023
@i0bs i0bs merged commit 3784072 into interactions-py:unstable Feb 3, 2023
@Damego Damego deleted the fix-modal-edit branch February 3, 2023 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants