Skip to content

Conversation

@artem30801
Copy link
Contributor

@artem30801 artem30801 commented Jun 13, 2021

About this pull request

Added support of component callbacks!
Rewiews on naming of functions, classes and arguments will be very appreciated, as some of the current method names feel too long or ambigous.

Changes

  • Extracted everything not related to function of slash commands from CommandObject to new CallbackObject base class
  • Added ComponentCallbackObject and CogComponentCallbackObject to hold component callback data (inherits from CallbackObject)
    • Thus, component callbacks support max_concurency, cooldowns, checks and individual error handlers (same as slash commands do now)
  • Added methods to SlashCommand to add, remove and manage component callbacks
    • add_component_callback to registeer function as component callback
      • Support of lists (including empty lists) of message and custom ids
      • custom_id defaults to function name in not specified
    • extend_component_callback to dynamically add combination of message_id and custom_id to existing callback object
    • get_component_callback to get component callback by message_id, custom_id, component_type
    • remove_component_callback to dynamically remove combination of message_id and custom_id from listening for callbacks
    • remove_component_callback_obj to remove all listeners (combinations of message_id and custom_id) assosiated with specified callback object
  • Added component_callback decorator to SlashCommand to register function as component callback
  • Added cog_component decorator to cog_ext to register cog method as component callback
  • Added on_component_callback event triggered along with actual component callback
  • Added component callback error handling event on_component_callback_error to work in same manner as slash commands do now

Checklist

  • I've checked this pull request runs on Python 3.6.X.
  • This fixes something in Issues.
    • Issue:
  • This adds something new.
  • There is/are breaking change(s).
  • (If required) Relevant documentation has been updated/added.
  • This is not a code change. (README, docs, etc.)

@LordOfPolls LordOfPolls requested review from LilSpazJoekp and i0bs June 17, 2021 09:11
Copy link
Contributor

@LilSpazJoekp LilSpazJoekp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few suggestions.

Copy link
Contributor

@i0bs i0bs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LordOfPolls LordOfPolls merged commit fb5be46 into interactions-py:components Jun 18, 2021
@artem30801 artem30801 deleted the artem30801-cog-comp-callbacks branch June 25, 2021 16:01
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.

5 participants