我目前正在制作一个经济机器人,到目前为止我有下面的代码。我收到一个错误 open_account(member)
未定义但它被定义为
async def open_acount(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"] = 100
with open("bank.json", "w") as f:
json.dump(users, f, indent=4)
return True
我的代码:
@bot.command()
async def balance(self, ctx, member : discord.Member = None):
if not member:
member = ctx.author
await open_account(member)
users = await get_bank_data()
user = member
wallet_amount = users[str(user.id)]["wallet"]
bank_amount = users[str(user.id)]["bank"]
embed=discord.Embed(title=f"{ctx.author.mention}'s Balance:", color=0x00FFFF)
embed.add_field(name="Wallet", value= wallet_amount, incline=False)
embed.add_field(name="Bank", value= bank_amount, incline=False)
await ctx.send(embed=embed)
我怎样才能正确定义它?谢谢
答案 0 :(得分:1)
您的代码中有一个拼写错误:account
也被错误地拼写为 acount
。