我正在编写一个机器人,它根据 Discord id 在 Discord 上为特定游戏组织锦标赛。我正在使用 client.wait_for
等待 竖起大拇指 反应,但它似乎没有停止,即使它有多个反应与描述匹配。没有错误,它只是什么都不做。代码如下:
! 客户端位于另一个名为 private
的文件中。
def check(reaction, user):
return(str(reaction.emoji) == '\N{THUMBS UP SIGN}')
try:
user = await private.client.wait_for('reaction_add', check=check, timeout = 60.0 )
except asyncio.TimeoutError:
print("exception caught")
return
else:
...
答案 0 :(得分:0)
您确定“大拇指向上”是正确的表情符号吗?以下是如何在 Discord.py 中等待反应添加的代码示例。
@client.command()
async def reactcheck(ctx):
xyz = True
if xyz == True:
await ctx.send('Send me that ? reaction, mate')
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) == '?'
try:
await client.wait_for('reaction_add', timeout=10.0, check=check)
await ctx.send('?')
except asyncio.TimeoutError:
await ctx.send('?')