如何检查用户的反应?我正在使用该代码:
@client.command()
async def react(ctx):
message = await ctx.send("Test")
await question.add_reaction("<?>")
await question.add_reaction("<?>")
如果用户用react响应消息,我该怎么办?如果用户用to响应消息,我又该怎么办?预先谢谢你
答案 0 :(得分:1)
在documentation中,您可以找到client.wait_for()
,它等待事件发生。文档中的示例应为您提供帮助:
@client.event
async def on_message(message):
if message.content.startswith('$thumb'):
channel = message.channel
await channel.send('Send me that ? reaction, mate')
def check(reaction, user):
return user == message.author and str(reaction.emoji) == '?'
try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await channel.send('?')
else:
await channel.send('?')