I know this is really bad, but it works and it was the only way with my current knowledge to complete the job. So I am looking for a "better" way in practice to write this.
Basically it shows 3 slots of images and those 3 slots change images with the random images listed in SLOT_PATTERN
. The images change using edit_message
to edit the previous 3 slot images that were there, replacing them with random images from the given list.
import discord, asyncio, time, random
client = discord.Client()
@client.event
async def on_message(message):
SLOT_PATTERN = [':four_leaf_clover:', ':moneybag:', ':cherries:', ':lemon:', ':grapes:', ':poop:', ':bell:', ':chocolate_bar:', ':watermelon:', ':six:', ':seven:', ':crown:']
wheel_pick1 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick2 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick3 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick4 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick5 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick6 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick7 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick8 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick9 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick10 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick11 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick12 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick13 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick14 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick15 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick16 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick17 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick18 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick19 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick20 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick21 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick22 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick23 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick24 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick25 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick26 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick27 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick28 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick29 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
wheel_pick30 = SLOT_PATTERN[random.randint(0, len(SLOT_PATTERN) - 1)]
if message.content.lower().startswith("!slots"):
slot1 = await client.send_message(message.channel, '%s %s %s' % (wheel_pick1, wheel_pick2, wheel_pick3))
time.sleep(0.25)
slot2 = await client.edit_message(slot1, '%s %s %s' % (wheel_pick4, wheel_pick5, wheel_pick6))
time.sleep(0.25)
slot3 = await client.edit_message(slot2, '%s %s %s' % (wheel_pick7, wheel_pick8, wheel_pick9))
time.sleep(0.50)
slot4 = await client.edit_message(slot3, '%s %s %s' % (wheel_pick10, wheel_pick11, wheel_pick12))
time.sleep(0.50)
slot5 = await client.edit_message(slot4, '%s %s %s' % (wheel_pick13, wheel_pick14, wheel_pick15))
time.sleep(0.75)
slot6 = await client.edit_message(slot5, '%s %s %s' % (wheel_pick16, wheel_pick17, wheel_pick18))
time.sleep(0.75)
slot7 = await client.edit_message(slot6, '%s %s %s' % (wheel_pick19, wheel_pick20, wheel_pick21))
time.sleep(1)
slot8 = await client.edit_message(slot7, '%s %s %s' % (wheel_pick22, wheel_pick23, wheel_pick24))
time.sleep(1)
slot9 = await client.edit_message(slot8, '%s %s %s' % (wheel_pick25, wheel_pick26, wheel_pick27))
time.sleep(1)
await client.edit_message(slot9, '%s %s %s' % (wheel_pick28, wheel_pick29, wheel_pick30))
client.run('clienttokenhere')