-
-
Notifications
You must be signed in to change notification settings - Fork 481
feat(ui): set_callback method #2985
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/2985/head:pr-2985
git checkout pr-2985This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2985/head |
|
Holding to think about more: https://canary.discord.com/channels/881207955029110855/881735314987708456/1435784975772287017 |
| elif self.parameters_amount == 2: | ||
| return self.func(interaction, self.item) # type: ignore # type checker doesn't like optional params | ||
| elif self.parameters_amount == 3: | ||
| return self.func(interaction, self.item, self.item.view) # type: ignore # type checker doesn't like optional params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't view be first ? It is most likely representing "self" in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, more people want access to the button/item rather than the view, so they can do (interaction, button) instead of having to do (interaction, view, button).
Paillat-dev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this, or do we want a callback __init__ param instead ? I feel like set_callback isn't that different from just doing .callback = but maybe I'm missing something. Also if we go this route, we could maybe use functools.partial instead of this proxy class. Idk just some thoughts
The main point is that the user can access the view and button, instead of only the interaction without subclassing or using the decorator in the view/row. Supporting partial and non async callbacks could be nice too ig. |
Summary
Convenient method to get all possible arguments without having to use subclass view and use the decorator.
WIP. Needs testing.
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.