I am making a bot in discord.py, and I want to call a function inside the code whenever someone presses a button. I looked at the documentation of discord_components(lib for buttons and select menus), but it’s either I’m stupid or the documentation is bad. I also googled it but didn’t find anything.
So is it possible to run a function on the interaction event?
>Solution :
@bot.event
async def on_button_click(interaction):
your_func()
You can just go with the flow. Be careful not to forget to send a callback.
Here is the link to the event examples on the discord components github: examples.