await open_account(ctx.author)
users = await get_bank_data()
earnings = (a_var3)
users[str(discord.user.id)]["Simp Wallet"] += earnings
@bot.command()
async def balance(ctx):
await open_account(ctx.author)
users = await get_bank_data()
wallet_amt = users[str(user.id)]["Simp Wallet"] = 0
bank_amt = users[str(user.id)]["Simp Bank"] = 0
em = discord.Embed(title = f"{ctx.author.name}'s Balance")
em.add_field(name = "Simp Wallet", value = wallet_amt)
em.add_field(name = "Simp Bank", value = bank_amt)
await ctx.send(embed = em)
async def open_account(user):
users = await get_bank_data()
if str(user.id) is users:
return False
else:
users[str(user.id)]["Simp Wallet"] = 0
users[str(user.id)]["Simp 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
Discord.ext.commands.errors.CommandInvokeError:命令引发异常:KeyError:'594750729810477063'。就是这么说的。我不是这方面的专家,所以,任何帮助将不胜感激!
完整回溯如下:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: '345878244756684801'
qq_花开花谢_0
相关分类