Reputation: 1
I'm trying to make a bot that, when asked to gamble, will pick a random number for the bot and yourself. My current code is this:
if message.content == ('-gamble'):
embed=discord.Embed(title="Challenge", description="To find a village, you must gamble with the
bot himself. Rolling the dice...", color=0xff0000)
await message.channel.send(embed=embed)
await asyncio.sleep(2)
choice = random.randrange(0,1)
if choice == 0:
embed=discord.Embed(title="Your Losing Gamble", description="You lose!\n\nThe bot
rolled 13 and you rolled 7.", color=0xff0000)
await message.channel.send(embed=embed)
if choice == 1:
embed=discord.Embed(title="Your Winning Gamble", description="You win!\n\nThe bot
rolled 4 and you rolled 15.", color=0xff0000)
await message.channel.send(embed=embed)
There's no error code. It just always lands on a losing gamble. I've tried spamming it, but it'll just always land on a loss. I've got no idea what's going on, any help would be greatly appreciated!
Upvotes: -1
Views: 220
Reputation: 1037
randrange(0, 1)
is returns always 0.
If you want to choose 0 or 1, you can use randrange(0, 2)
or randint(0, 1)
Upvotes: 1
Reputation: 472
You are asking to chosse between "0" and "0", as the second number is excluded.
Try
choice = random.randrange(0,2)
See Randrange documentation : https://docs.python.org/3/library/random.html
Upvotes: 2