I'm learning to code discord bots and I'm trying to add a 'money' function that will add 'money' to the user 'account' every time he sends a message.
Here's my problem, the json file writes 'id' : 0 but the python file write id : 0
from discord.ext import commands
import json
with open('money.json', 'r') as infile:
argent = json.load(money)
print(money)
@bot.event
async def on_message(message):
if not message.author.bot:
id = message.author.id
if id not in money:
argent[id] = 0.00
argent[id] += 5.00
print(money)
with open('money.json', 'w+') as outfile:
json.dump(argent, outfile)
Here's my problem, when python load the JSON file, it creates python dict('id' : value) but when python write in the dict, it writes dict(id : value)
dict loaded from JSON:
{'299561981311057920': 5.0}
Same dict after the program wrote on it :
{'299561981311057920': 5.0, 299561981311057920: 5.0}
I would like it to write:
{'299561981311057920': 10.0}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…