我正在尝试做一个机器人,用于在各种服务器上进行投票,而我原来的计票方法有一个重大缺陷,有了它,人们可以做出React,拿走React,然后多次重新添加,每次投票都会被统计,简而言之,它基本上允许人们进行多次投票,代码如下:
def check(reaction, user):
return user != '808555253317894163' and str(reaction.emoji) in ['👍', '👎']
yay = 0
nay = 0
loop = 0
while loop == 0:
try:
reaction, user = await bot.wait_for('reaction_add', timeout=timeLimit, check=check)
if reaction.emoji == '👍' and user != '808555253317894163':
yay += 1
if reaction.emoji == '👎' and user != '808555253317894163':
nay += 1
except:
await ctx.send(f'Yay: {yay}\nNay: {nay}')
if yay > nay:
await ctx.send('The vote comes out to yay!')
elif yay < nay:
await ctx.send('The vote comes out to nay!')
elif yay == nay:
await ctx.send('The vote is a tie!')
loop = 1
我想改变它,这样在时间限制后,它只计算竖起大拇指和放下大拇指的React,然后从每个减1(考虑到机器人的React)。唯一的另一个帖子,这是接近我想要检查只有竖起大拇指的React。有人知道我怎么做吗?
1条答案
按热度按时间xoshrz7s1#
用多米尼克在这篇文章中说的话,我找到了我的问题的答案: