So im trying to make a little Economy Bot and im trying to make a commands for the user to gain coins. I copied a code I found on here and tweaked it a bit but it still doesn't work like I want it to.
This is the code I currently have
settings = json.load(open("testing.json", encoding="utf-8"))
@client.command()
async def beg(ctx):
await account(ctx.author)
user = ctx.author
users = await data()
earning = random.randint(0,101)
await ctx.send(f"Someone gave you {earning}")
async def account(user):
await data()
users1 = settings["users"]
if int(user.id) in users1:
return False
else:
settings["users"].append(int(user.id))
json.dump(settings, open("testing.json", "w", encoding="utf-8"), indent=4)
settings["wallet"].append(0)
json.dump(settings, open("testing.json", "w", encoding="utf-8"), indent=4)
async def data():
with open("testing.json") as file:
accounts = json.load(file)
return accounts
I cant get it to make a Wallet just for just one user with there ID and then add a amount to his "wallet". I tried a few ways but nothing works and getting the value to display it in a Wallet command didnt work either. Im greatfull for any Help I get.
{
"users": [
],
"wallet": [
]
}
This is how the json looks like.