【问题标题】:Discord.py - Check reactions after someone reacts for the 1st timeDiscord.py - 在有人第一次做出反应后检查反应
【发布时间】:2020-11-24 00:33:29
【问题描述】:

vote_msg = await ctx.send(embed=embed)
    await vote_msg.add_reaction('✅')
    await vote_msg.add_reaction('❎')
    reaction, member = await ctx.bot.wait_for('reaction_add')
    vote_msg = await vote_msg.channel.fetch_message(vote_msg.id) # refetch message
    # default values
    positive = 0
    negative = 0
    for reaction in vote_msg.reactions:
        if reaction.emoji == '✅':
            positive = reaction.count - 1
        elif reaction.emoji == '❎':
            negative = reaction.count - 1
    print(positive)
    print(negative)

目前我有这个来重新获取消息的反应,我怎样才能让它在有人第一次反应后重新获取它,而不是让它等待 5 秒并检查?

【问题讨论】:

    标签: python python-3.x discord discord.py discord.py-rewrite


    【解决方案1】:

    我想你正在寻找on_reaction listener

    您可以从reaction.message.reactions 访问所有消息反应 如下:

    @bot.event
    async def on_reaction_add(reaction, user):
        reactions = reaction.message.reactions
        # DO WHAT YOU WANT HERE
        
    

    【讨论】:

      猜你喜欢
      • 2021-03-04
      • 2021-06-28
      • 1970-01-01
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      相关资源
      最近更新 更多