如果机器人要发送消息
vote_msg = await ctx.channel.send('Vote ' + '@' + str(member) + ' out of the server? **' + str(out) + '/' + str(of) + '**')
await vote_msg.add_reaction('✅')
await vote_msg.add_reaction('❎')
如何让机器人在30秒后汇总反应?
答案 0 :(得分:0)
使用message.reactions
:Documentation
vote_msg = await ctx.channel.send('Vote ' + '@' + str(member) + ' out of the server? **' + str(out) + '/' + str(of) + '**')
await vote_msg.add_reaction('✅')
await vote_msg.add_reaction('❎')
await asyncio.sleep(30) # wait 30 seconds with the asyncio module (import asyncio if you haven't already)
vote_msg = await vote_msg.channel.fetch_message(vote_msg.id) # refetch message
# default values
positive = 0
negative = 0
for reaction in vote_msg.reactions:
if reaction.emoji == '✅':
positive = reaction.count - 1 # compensate for the bot adding the first reaction
if reaction.emoji == '❎':
negative = reaction.count - 1
print(f'Vote Result: {positive} positive and {negative} negative reactions')