【发布时间】:2021-05-21 12:42:36
【问题描述】:
我有一个经济机器人,我正在发出 give 命令。我已经设置好了,这样你就可以输入>give @whoever 5,机器人将从你的钱包中取出 5 个并将 5 个添加到其他人的钱包中。但即使我有足够的钱给别人,机器人也会说我没有那么多钱可以给。
如您在上面看到的,我的帐户中有 200 个,但如果我尝试提供 200 或 50 个等。他们的机器人会回复:
代码:
@bot.command()
async def give(ctx, member : discord.Member, amount=None):
await open_account(ctx.author)
await open_account(member)
if amount == None:
await ctx.send(f"{ctx.author.mention}, Please enter the amount that you want to give!")
return
users = await get_bank_data()
user = member
bal = users[str(user.id)]["wallet"]
amount = int(amount)
if amount < 1:
await ctx.send(f"{ctx.author.mention}, Your amount needs to be larger than 0!")
return
if amount > bal:
await ctx.send(f"{ctx.author.mention}, You do not have enough money in your wallet to do this!")
return
if amount < bal:
await update_bank(ctx.author,-1*amount,"wallet")
await update_bank(member,amount,"wallet")
await ctx.send(f"{ctx.author.mention}, You just gave `{amount}` Ulti Coins to {member.name}!")
我什至在if amount > bal: 之后有一个返回声明,但这似乎不起作用。我怎样才能让我的机器人知道我实际上有足够的付出?
【问题讨论】:
-
您能否添加您正在调用的导致机器人发送“您没有足够...”的确切命令?
-
@JacobLee 这是
>give @member (any number)除了0 及以下我给出的任何数字,即使我有足够的钱,它也会给我这个错误。 -
包含所有用户钱包数据的字典是否被修改过?即,目前,机器人现在使用的数据是否与提供的数据相同?
-
从那以后我没有改变它。
-
只是确认一下,机器人没有修改它,对吗?
标签: python discord.py