Python 不和谐经济命令不起作用有人知道为什么吗?

Python 不和谐经济命令不起作用有人知道为什么吗?,python,discord,discord.py,Python,Discord,Discord.py,因此,我正在用python为discord制作一个机器人,它是一个经济型机器人,它将所有数据存储在一个名为“MainBank.json”的json文件中。除了一件事,就是当你试图将钱存入银行或试图从银行取款时,一切正常。我不认为这有什么问题 @bot.command() async def withdraw(ctx,amount = None): await open_account(ctx.author) if amount == None: await ct

因此,我正在用python为discord制作一个机器人,它是一个经济型机器人,它将所有数据存储在一个名为“MainBank.json”的json文件中。除了一件事,就是当你试图将钱存入银行或试图从银行取款时,一切正常。我不认为这有什么问题

@bot.command()
async def withdraw(ctx,amount = None):
    await open_account(ctx.author)

    if amount == None:
        await ctx.send("Please enter a valid amount!")
        return
  
    bal = await update_bank(ctx.author)

    amount = int(amount)
    if amount>bal[1]:
        await ctx.send("You don't have enough potatoes in your bank!")
        return
    if amount<0:
        await ctx.send("Please enter a valid amount!")
        return

        await update_bank(ctx.author,amount, "wallet")
        await update_bank(ctx.author,-1*amount, "bank")

        await ctx.send(f"You withdrew {amount} potatoes!")

@bot.command()
async def deposit(ctx,amount = None):
    await open_account(ctx.author)

    if amount == None:
        await ctx.send("Please enter a valid amount!")
        return
  
    bal = await update_bank(ctx.author)

    amount = int(amount)
    if amount>bal[0]:
        await ctx.send("You don't have enough potatoes in your wallet!")
        return
    if amount<0:
        await ctx.send("Please enter a valid amount!")
        return

        await update_bank(ctx.author, -1*amount)
        await update_bank(ctx.author, amount, "bank")

        await ctx.send(f"You deposited {amount} potatoes!")

async def open_account(user):

  users = await get_bank_data()

  if str(user.id) in users:
      return False
  else:
      users[str(user.id)] = {}
      users[str(user.id)]["wallet"] = 0
      users[str(user.id)]["bank"] = 0

  with open("MainBank.json", "w") as f:
      json.dump(users,f)
  return True

async def get_bank_data():
    with open("MainBank.json", "r") as f:
      users = json.load(f)

    return users



async def update_bank(user,change = 0,mode = "wallet"):
  users = await get_bank_data()

  users[str(user.id)][mode] += change

  with open("MainBank.json", "w") as f:
      json.dump(users,f)

  bal = [users[str(user.id)]["wallet"],users[str(user.id)]["bank"]]
  return bal
@bot.command()
异步def提取(ctx,金额=无):
等待开户(ctx.author)
如果金额==无:
等待ctx.send(“请输入有效金额!”)
返回
bal=等待更新银行(ctx.author)
金额=整数(金额)
如果金额>余额[1]:
等待ctx.send(“你的银行里没有足够的土豆!”)
返回
如果金额为[0]:
等待ctx.send(“你的钱包里没有足够的土豆!”)
返回

如果数量你绝对要注意正确的缩进。 我注意到
draw
命令出现以下错误:


如果有数量,请在执行命令后添加跟踪卡。如果没有任何错误,很难判断问题出在哪里。我怀疑您想查看
if值