#Add callback to button that exists conditionally
1 messages · Page 1 of 1 (latest)
Check condition, add component, or don't add component?
A shot in the dark as I haven't done this, but could a listener that checks for interaction of the custom id of said button/selects that may or mat not exist work?
Uh, why not?
My solution was to create a modified Button object which implements this feature;
class CallbackButton(disnake.ui.Button):
def __init__(self, callback:Callable[[disnake.MessageInteraction], None], **kwargs) -> None:
super().__init__(**kwargs)
self.callback = callback
Wouldn't you want the callback to be asynchronous though
This implementation seems to work just fine with async functions
they were mostly referring to the fact that your callback typehint is not asynchronous