mercredi 20 fรฉvrier 2019

Random.Randint() Repeating

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