0

enter image description hereim making a economy bot at the moment and so far i have the code below. Im getting an error that open_account(member) is not defined but it's defined as

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

My code:

@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)

How can i get this to be defined properly? Thanks

8
  • can you post the whole traceback please? Commented May 18, 2021 at 21:07
  • im not getting an error, i just have the red squiggly lines under await open_account(member) i also added a screenshot Commented May 18, 2021 at 21:08
  • does the code itself work? Commented May 18, 2021 at 21:10
  • when i run the command, nothing happens. Im guessing because await open_account(member) is not defined so it cant run. Commented May 18, 2021 at 21:12
  • 1
    I just got it working, there is a typo lmao Commented May 18, 2021 at 21:30

1 Answer 1

1

You havs a typo in your code: account is invorrectly spelled as acount as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.