所以,我试图通过这段代码做出反应
@client.command()
async def test(ctx):
msg = await ctx.send("Eh idk just react")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) in ['⬅️', '➡️']
try:
reaction, user = await client.wait_for('reaction_add', timeout=5, check=check)
if reaction == '➡️':
await ctx.send("NEEXT!")
return
elif reaction == '⬅️':
await ctx.send("RETUUURN!")
return
except asyncio.TimeoutError:
await ctx.send("Timed out")
但是当添加反应时,它什么也没做。有人能帮我吗?我需要1周的反应帮助。
答案 0 :(得分:2)
与Unicode表情符号进行比较时,您需要使用reaction.emoji
。
@client.command()
async def test(ctx):
msg = await ctx.send("Eh idk just react")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) in ['⬅️', '➡️']
try:
reaction, user = await client.wait_for('reaction_add', timeout=5, check=check)
if reaction.emoji == '➡️':
await ctx.send("NEEXT!")
return
elif reaction.emoji == '⬅️':
await ctx.send("RETUUURN!")
return
except asyncio.TimeoutError:
await ctx.send("Timed out")