Okay so im making a currency bot, and im stuck at the rob command.
Is that possible to add "chances" to the code? i mean that when someone executes the command then ex: 45% that the robbery will not succeed? If yes, then how?
>Solution :
yes, there is a way to do randomness in python. It is to use the random module.
Here’s the rob command example :
@bot.command()
async def rob(ctx):
if random.randint(0, 100) <= 45:
await ctx.send("Robbery has failed.")
else:
await ctx.send("Robbery was successful.")
Don’t forget to add import random in your code before referencing it, preferably add it at the top of your code
