feat(ui): set_callback method#2985
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.
Shouldn't view be first ? It is most likely representing "self" in this case
There was a problem hiding this comment.
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.
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.