Build view buttons programatically #9025
-
Hi guys, Is there any way to build dynamically a view with buttons? I found I can use something like:
But how can I define which button is pressed? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There are many examples here you can follow: https://github.com/Rapptz/discord.py/tree/master/examples/views The tic_tac_toe example shows an organized way of creating a Note that the button callback actually receives the button, so you can check its When using the decorator, |
Beta Was this translation helpful? Give feedback.
There are many examples here you can follow:
https://github.com/Rapptz/discord.py/tree/master/examples/views
The tic_tac_toe example shows an organized way of creating a
Button
subclass with a callback and adding them dynamically to the view in the constructor.Note that the button callback actually receives the button, so you can check its
label
,custom_id
, or other attributes in the callback.When using the decorator,
button
comes after theinteraction
. When constructing a button usingButton
class, theself
parameter is the button.