我是一个绝对的初学者,只是提一下。所以机器人应该理解(显示为消息“ThumbUp/ThumbDown”)用户已经对已经存在的反应做出反应。我的问题是,如果我对两种反应之一做出反应,两条消息都会发出,所以我想我需要以某种方式将它们分开。任何人都可以帮助我吗?
@client.event
async def on_reaction_add(reaction, user):
reaction == get(message.reactions, emoji='?')
if reaction.count > 1:
await message.channel.send('ThumbUp')
await helpmessage.delete()
else:
await asyncio.sleep(30)
await helpmessage.delete()
reaction == get(message.reactions, emoji='?')
if reaction.count > 1:
await message.channel.send('ThumbDown')
await helpmessage.delete()
else:
await asyncio.sleep(30)
await helpmessage.delete()
答案 0 :(得分:0)
有几种方法:
@client.event
async def on_reaction_add(reaction, user):
reaction = get(message.reactions, emoji='?')
if reaction.count > 1:
await message.channel.send('ThumbUp')
else:
reaction = get(message.reactions, emoji='?')
if reaction.count > 1:
await message.channel.send('ThumbDown')
else:
await asyncio.sleep(30)
await helpmessage.delete()
@client.event
async def on_reaction_add(reaction, user):
checks = {'?': 'ThumbUp', '?': 'ThumbDown'}
for emoji, msg in checks.items():
reaction = get(message.reactions, emoji=emoji)
if reaction.count > 1:
await message.channel.send(msg)
break
else:
await asyncio.sleep(30)
await helpmessage.delete()
答案 1 :(得分:0)
似乎修复是在行中添加第二个 =
,其中 reaction
被确定。所以它是 reaction == get(helpmessage.reactions, emoji="?")