Ask coding questions

← Back to all posts
Random Only Picks One
FounderRoomyfoo (0)

Output On Discord

Input On Replit

There Are 3 Choices But Only Is Picking Number Two Choice

Help Will Be The Best

Answered by ch1ck3n (2393) [earned 5 cycles]
View Answer
Comments
hotnewtop
ch1ck3n (2393)

ohh i see why

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith(':Chest-Roll'):
        await message.channel.send('Rolling For Reward')
        await message.channel.send(random.choice(chest))

is what you actually need for the thingy majigy

because random doesn't actually choose a new one every time you call it

ch1ck3n (2393)

@FounderRoomyfoo next time just share the repl not just a screenshot ok?

CosmicBear (56)

It set the value for "chestp" only once so every time someone says ":Chest-Roll" then the number 2 choice will be sent because chestp is only the number 2 choice.

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith(':Chest-Roll'):
	chest=['You Got Nothing','Nothing But Cobwebs','You Found A Chest!!!']
	chestp = random.choice(chest)
        await message.channel.send('Rolling For Reward')
        await message.channel.send(chestp)
FounderRoomyfoo (0)

@CosmicBear I already fixed it but thank you for the other way!!!

ch1ck3n (2393)

please send the actual code instead of a screenshot pleas