Python 在不和谐中等待

Python 在不和谐中等待,python,discord,discord.py,Python,Discord,Discord.py,我正在做一个计算器命令,我做了这个代码 @commands.command(brief="Test") async def calc(self, ctx, num1: int, num2: int): # TODO: Make this look better reaction = [ '\U0001f1e6', '\U0001f1f8', '\U0001f1f2', '

我正在做一个计算器命令,我做了这个代码

@commands.command(brief="Test")
async def calc(self, ctx, num1: int, num2: int):
    # TODO: Make this look better

reaction = [
            '\U0001f1e6',
            '\U0001f1f8',
            '\U0001f1f2',
            '\U0001f1e9'
]

embed=discord.Embed(title="Calculator", description="Chose one of the following Operations \n \n1)Addition (+) \n2)Subbraction (-)\n3)Multiplication (x)\n4)Division (/)", color=0x93e6fb)
embed.set_footer(text=f"React with the emoji you want as Operator")
message = await ctx.send(embed=embed)
for i in reaction:
    await message.add_reaction(i)

def check(reaction, user):
    return str(reaction.emoji) == '\U0001f1e6', '\U0001f1f8', '\U0001f1f2', '\U0001f1e9' and reaction.message == message and user == ctx.author

try:
    reaction, user = await self.bot.wait_for('reaction_add', timeout=10.0, check=check)
except asyncio.TimeoutError:
    await ctx.message.delete()
    await message.delete()
else:
    if str(reaction.emoji) == '\U0001f1e6':
        value = num1 + num2
        print(value)
        await ctx.send(value)
    elif str(reaction.emoji) == '\U0001f1f8':
        value = num1 - num2
        print(value)
        await ctx.send(value)
    elif str(reaction.emoji) == '\U0001f1f2':
        value = num1 * num2
        print(value)
        await ctx.send(value)
    elif str(reaction.emoji) == '\U0001f1e9':
        value = num1 / num2
        print(value)
        await ctx.send(value)
当我使用这个命令的时候,它会默认为最后一个Elif语句,有时它会完美地工作,请帮助 提前谢谢。

这个

str(reaction.emoji)='\U0001f1e6'、'\u0001f8'、'\u0001f2f2'、'\U0001f1e9'
不是有效的python语句,如果要比较某个反应是否是其中的任何一个,可以使用列表和关键字中的

['\U0001f1e6'、'\U0001f1f8'、'\U0001f1f2'、'\U0001f1e9']中的str(反应)#您也可以使用之前定义的“反应”列表