Python discord.py“;等待;命令中的反应

Python discord.py“;等待;命令中的反应,python,discord.py,Python,Discord.py,我已经写了一个命令。执行此命令时,bot将向特定通道发送消息。他对这条消息添加了一个反应(顺便说一句)。到目前为止。但是现在,当有人点击这个反应时,我希望机器人做出反应。在这种情况下,他应该向特定频道发送消息。但这不起作用。也没有错误代码,这意味着它可以工作,只是他不发送消息 @bot.command() async def buy(ctx, choice): channel = bot.get_channel(705836078082424914) user = ctx.mes

我已经写了一个命令。执行此命令时,bot将向特定通道发送消息。他对这条消息添加了一个反应(顺便说一句)。到目前为止。但是现在,当有人点击这个反应时,我希望机器人做出反应。在这种情况下,他应该向特定频道发送消息。但这不起作用。也没有错误代码,这意味着它可以工作,只是他不发送消息

@bot.command()
async def buy(ctx, choice):
    channel = bot.get_channel(705836078082424914)
    user = ctx.message.author
    vcrole1 = get(user.guild.roles, id=703562188224331777)
    messagechannel = ctx.message.channel.id
    if ctx.message.channel.id == 705146663135871106:
        if choice == '1':
            if any(role.id == 703562188224331777 for role in ctx.message.author.roles):
                await user.remove_roles(vcrole1)
                await ctx.send(
                    "not important message")
                messtag1 = await channel.send('not important') 
                await messtag1.delete(delay=None)

                embed = discord.Embed(color=0xe02522, title='not important title', description=
                'not important description')
                embed.set_footer(text='not important text')
                embed.timestamp = datetime.datetime.utcnow()

                mess1 = await channel.send(embed=embed)
                await mess1.add_reaction('<a:check:674039577882918931>')

                def check(reaction, user):

                    return reaction.message == mess1 and str(reaction.emoji) ==  '<a:check:674039577882918931>'

                await bot.wait_for('reaction_add', check=check)
                channeldone = bot.get_channel(705836078082424914)
                await channeldone.send('test')
@bot.command()
异步def购买(ctx,选项):
通道=机器人获取通道(70583607808424914)
user=ctx.message.author
vcrole1=get(user.guild.roles,id=703562188224331777)
messagechannel=ctx.message.channel.id
如果ctx.message.channel.id==705146663135871106:
如果选项==“1”:
如果有(对于ctx.message.author.roles中的角色,role.id==703562188224331777):
等待用户。删除_角色(vcrole1)
等待ctx发送(
“不重要的信息”)
messtag1=等待通道.send('不重要')
等待消息tag1.delete(延迟=无)
嵌入=discord.embed(颜色=0xe02522,title='not important title',说明=
'不重要的描述')
嵌入.set_页脚(text='not important text')
embed.timestamp=datetime.datetime.utcnow()
mess1=等待通道.send(嵌入=嵌入)
等待消息1。添加反应(“”)
def检查(反应、用户):
return reaction.message==mess1和str(reaction.emoji)=''
等待机器人。等待('反应添加',检查=检查)
channeldone=bot.get_通道(705836078082424914)
等待通道完成。发送('测试')

没有错误消息。

它看起来像是您的
反应。message==mess1
条件正在返回
False
,我无法将其缩小到发生这种情况的原因,但如果我这样做,我将编辑此消息

克服此问题的一种方法是评估消息的ID:

return reaction.message.id==mess1.id和str(reaction.emoji)='

  • 输出中是否有错误消息?不,没有错误消息。