Reputation: 909
Below code works fine when I use !luck xx
and when the amount is low it will say the amount is low, but when I use !luck -xx
it still keeps adding the amount.
So how to disable using the -xx amount
@bot.command(pass_context=True)
async def luck(ctx, amounty: int):
primary_id = ctx.message.author.id
if primary_id not in amounts:
await bot.say("not registered")
elif amounts[primary_id] < amounty:
await bot.say("low balance")
else:
amounts[primary_id] -= amounty
a = random.randint(1,2)
if a == 1:
amounts[primary_id] += amounty * 2
await bot.say("You Won")
else:
await bot.say("You lost")
Upvotes: 0
Views: 183
Reputation: 2408
Just check if the number is negative and if so do an empty return
if amounty<0:
await bot.say("Can't use a negative number")
return
Upvotes: 1