I have a discord bot saves the users info in a json file like this: https://imgur.com/hM399Pw
So I need to add a new json key (name="House", value=False) to all users.
I tried before json.dump(house, json_file) bot not works.
Important info: I have these functions:
To open a new json account:
async def open_account(user):
users = await get_bank_data()
if str(user.id) in users:
house = users[str(user.id)]['House'] = False
with open("main.json", 'w') as f:
f.write(json.dumps(house))
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["wallet"] = 0
users[str(user.id)]["bank"] = 0
users[str(user.id)]["House"] = False
To read json file:
async def get_bank_data():
with open("main.json", "r") as f:
users = json.load(f)
return users
Another info: user value is ctx.author