Command Raised an exception: TypeError: string indicies must be integers

Command Raised an exception: TypeError: string indicies must be integers

我正在编写一个 discord.py 机器人,我有一个名为 slots 的命令。 我正在使用一个函数来更新运行命令的用户的余额。 代码是。

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

但是标题中的错误就在这一行

    bal = [users[str(user.id)["wallet"], users[str(user.id)]["bank"]]]

这是堆栈跟踪

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/container/cogs/slots.py", line 54, in slots
    bal = await update_bank(ctx.author.id)
  File "/home/container/cogs/slots.py", line 38, in update_bank
    bal = [users[str(user)["wallet"], users[str(user)]["bank"]]]
TypeError: string indices must be integers

如果有人能提供帮助那就太好了

很确定您只是在这里遗漏了方括号

bal = [users[str(user.id) ->]<- ["wallet"], users[str(user.id)]["bank"]]]