当我使用!luck xx
时,下面的代码运行得很好,当数量很低时,它会显示数量很低,但当我使用!luck -xx
时,它仍然会不断添加数量。
那么如何禁用使用-xx数量呢
@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")
发布于 2018-09-26 07:45:24
只需检查数字是否为负数,如果是,则返回一个空
if amounty<0:
await bot.say("Can't use a negative number")
return
https://stackoverflow.com/questions/52507952
复制相似问题