Files
Gwendolyn/funcs/games/money.py
NikolajDanger 5c31877656 📄Updated help files
2020-07-27 19:40:42 +02:00

41 lines
1.1 KiB
Python

import json
from funcs import logThis
def checkBalance(user):
with open("resources/games.json", "r") as f:
data = json.load(f)
if user in data["users"]:
return data["users"][user]
else: return 0
def addMoney(user,amount):
with open("resources/games.json", "r") as f:
data = json.load(f)
if user in data["users"]:
points = data["users"][user]
data["users"][user] = points + amount
else:
data["users"][user] = amount
with open("resources/games.json", "w") as f:
json.dump(data,f,indent=4)
def giveMoney(user,targetUser,amount):
with open("resources/games.json", "r") as f:
data = json.load(f)
if user in data["users"]:
if data["users"][user] >= amount:
addMoney(user,-1 * amount)
addMoney(targetUser,amount)
return "Transferred the GwendoBucks"
else:
logThis("They didn't have enough GwendoBucks")
return "You don't have that many GwendoBucks"
else:
logThis("They didn't have enough GwendoBucks")
return "You don't have that many GwendoBucks"