【问题标题】:I want to make a command using discord.py which triggers when someone react to the message我想使用 discord.py 发出命令,当有人对消息做出反应时触发
【发布时间】:2021-01-24 19:08:12
【问题描述】:
async def qna(ctx):
    msg = await ctx.send('what is the color of mango\na. red\nb. blue')
    await msg.add_reaction("????️")
    await msg.add_reaction("????️")]

这是我到现在为止所做的???? 请有人帮帮我?

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您正在寻找Bot.wait_for

    async def qna(ctx):
        reactions = ["?️", "?️"]
        msg = await ctx.send('what is the color of mango\na. red\nb. blue')
        for r in reactions:
            await msg.add_reaction(r)
    
        def check(reaction, user):
            return user == ctx.author and reaction.message == msg and str(reaction) in reactions
    
        reaction, user = await bot.wait_for("reaction_add", check=check)
        # Do something with the reactions
    

    参考:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-29
      • 2021-04-11
      • 1970-01-01
      • 2021-06-05
      • 2020-12-13
      • 2020-11-07
      • 2021-08-30
      • 2021-07-18
      相关资源
      最近更新 更多