首页 > 解决方案 > Discord.py 查找谁对消息做出了反应

问题描述

我正在编写一个不和谐的机器人并创建一个游戏。我需要让使用特定表情符号对消息做出反应的用户添加到列表中。我怎样才能做到这一点?

(下面是我的代码)

@client.command(aliases=['rr'])
async def roletarussa(ctx):
    embed = discord.Embed(title="ROLETA RUSSA", description="Reaja com ✅ para participar!")
    embed.set_thumbnail(
        url="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRa7rdwxpSOiReyDvnVd6MzqDg33rtQrxhoUw&usqp=CAU")
    embed.add_field(name="Só os brabo consegue entrar nesse web desafio ",
                    value="Vai logo entra nesse bagaça medroso!", inline=False)
    embed.set_image(url='https://media1.tenor.com/images/64e0334d77b0976b808147bd160b8534/tenor.gif?itemid=12379724')
    message = await ctx.send(embed=embed)

    await message.add_reaction("✅")

    def check(reaction, user):
        return user == ctx.author and str(reaction.emoji) in ['✅']
       

    while True:
        try:

            reaction, user = await client.wait_for("reaction_add", timeout=60, check=check)
           

            if str(reaction.emoji) == "✅":
                await ctx.send('{} vai participar'.format(user))
                await message.remove_reaction(reaction, user)

            else:
                await message.remove_reaction(reaction, user)
                
        except asyncio.TimeoutError:
            await message.delete()
            break
            # ending the loop if user doesn't react after x seconds

        @client.command()
        async def startrr(ctx):
            players = []
            maxlenght = 6
            while len(players) < maxlenght:
                rrp = ctx.message.author.mention
                players.append(rrp)
                players = list(set(players))
            else:
                await ctx.send('Sem mais vagas para o jogo.')
            await ctx.send(players)

我需要知道谁对消息做出反应并存储在“玩家”列表中。

标签: pythondiscord.pydiscord.py-rewrite

解决方案


推荐阅读