【问题标题】:Call a python function on button click in discord_components (python)在 discord_components (python) 中单击按钮时调用 python 函数
【发布时间】:2021-12-31 11:28:30
【问题描述】:

我正在discord.py 中制作一个机器人,并且我想在有人按下按钮时调用代码中的一个函数。我查看了discord_components(按钮和选择菜单的lib)的文档,但要么我很愚蠢,要么文档很糟糕。我也用谷歌搜索了它,但没有找到任何东西。

那么是否可以在交互事件上运行函数?

【问题讨论】:

    标签: python discord discord.py interaction


    【解决方案1】:
    @bot.event
    async def on_button_click(interaction):
        your_func()
    

    你可以随波逐流。注意不要忘记发送回调。 以下是不和谐组件 github 上事件示例的链接:examples

    【讨论】:

      猜你喜欢
      • 2018-03-03
      • 2021-10-17
      • 2021-10-08
      • 1970-01-01
      • 2020-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多