Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass event object based on listeners signature #1367

Merged
merged 6 commits into from
May 3, 2023

Conversation

artem30801
Copy link
Contributor

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description & changes

Event object is now passed (or not) based on whether there are any parameters in listener

Test Scenarios

Tested on my bot and with test script - both as standalone function listeners and as extension methods

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@LordOfPolls
Copy link
Contributor

Purely because I'm certain we are going to get people saying "hOw Do I gEt ThE EvEnT" can you make the listener throw a warning if an event that would normally have a Param (ie any apart from startup and ready) don't on instantiation?

@LordOfPolls
Copy link
Contributor

Also, would it be worth moving the inspect call to the listeners instantiation too, as inspect is very expensive, and this is a high traffic part of the lib

@artem30801 artem30801 requested a review from silasary May 1, 2023 10:53
interactions/models/internal/listener.py Outdated Show resolved Hide resolved
Copy link
Member

@silasary silasary left a comment

Choose a reason for hiding this comment

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

That's a lot nicer looking 😄

@LordOfPolls LordOfPolls merged commit 8c5cf71 into interactions-py:unstable May 3, 2023
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.

4 participants