I have this game where you need to react with the 5 random emojis sent from a list. The problem is that sometimes random.randint()
spits out the same emoji twice so its impossible react twice to the same message with the same emoji. Is there a better way of doing multiple random.randints?
async def food_loop():
await client.wait_until_ready()
channel = client.get_channel("523262029440483329")
while not client.is_closed:
foodtime = random.randint(1440, 1880)
food = ['🍇','🍈','🍉','🍊','🍋','🍌','🍍','🍎','🍏','🍐','🍑','🍒','🍓','🥝','🍅','🥑','🍆','🥔','🥕','🌽','🌶',
'🥒','🍄','🥜','🌰','🍞','🥐','🥖','🥞','🧀','🍖','🍗','🥓','🍔','🍟','🍕','🌭','🌮','🌯',
'🥙','🍳','🥘','🍲','🥗','🍿','🍱','🍘','🍙','🍚','🍛','🍜','🍝','🍠','🍢','🍣','🍤','🍥','🍡',
'🍦','🍧','🍨','🍩','🍪','🎂','🍰','🍫','🍬','🍭','🍮','🥛','☕','🍵','🍶','🍾','🍷','🍸','🍹','🍺',
'🥃']
food1 = food[random.randint(0,79)]
food2 = food[random.randint(0,79)]
food3 = food[random.randint(0,79)]
food4 = food[random.randint(0,79)]
food5 = food[random.randint(0,79)]
foodmonies = random.randint(350,750)
up = 'order up'
def orderup(m):
return m.content.lower() == up
foodmsg = 'Customer has ordered {}, {}, {}, {}, and {}! Fulfill their order ASAP!'.format(food1, food2, food3, food4, food5)
foodmsgsend = await client.send_message(channel, foodmsg)
foodpay1 = await client.wait_for_reaction(emoji=food1, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay2 = await client.wait_for_reaction(emoji=food2, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay3 = await client.wait_for_reaction(emoji=food3, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay4 = await client.wait_for_reaction(emoji=food4, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodpay5 = await client.wait_for_reaction(emoji=food5, message=foodmsgsend, timeout=3600,
check=lambda reaction, user: user != client.user)
foodguess = await client.wait_for_message(timeout=3600, channel=channel, check=orderup)
if foodpay1 and foodpay2 and foodpay3 and foodpay4 and foodpay5 and foodpay3.user.id in blacklist:
pass
else:
if foodpay1 and foodpay2 and foodpay3 and foodpay4 and foodpay5 and foodguess:
await client.delete_message(foodmsgsend)
await client.send_message(channel, "{} fulfills the order and earns ${}".format(foodpay5.user.mention, foodmonies))
add_dollars(foodpay5.user, foodmonies)
await asyncio.sleep(int(foodtime))
Aucun commentaire:
Enregistrer un commentaire