This repository has been archived on 2024-10-14. You can view files and clone it, but cannot push or open issues or pull requests.
AutoZoomDiscord/modules/functions_bot.py

45 lines
1.1 KiB
Python
Raw Normal View History

2022-09-14 14:02:06 +03:00
# -*- coding: utf-8 -*-
2022-09-14 13:48:58 +03:00
from modules.functions import jsonLoad, jsonSave
def locale(key, *args):
strings = jsonLoad("strings.json")
string = strings
for dict_key in args:
string = string[dict_key]
return string[key]
def configGet(key):
return jsonLoad("config.json")[key]
def configAppend(key, value):
config = jsonLoad("config.json")
config[key].append(value)
jsonSave("config.json", config)
def configRemove(key, value):
config = jsonLoad("config.json")
config[key].remove(value)
jsonSave("config.json", config)
def userSet(userid, key, value):
user = jsonLoad(f"data/users/{userid}.json")
user[key] = value
jsonSave(f"data/users/{userid}.json", user)
def userGet(userid, key):
try:
return jsonLoad(f"data/users/{userid}.json")[key]
except KeyError:
return None
except FileNotFoundError:
return None
def userClear(userid, key):
try:
user = jsonLoad(f"data/users/{userid}.json")
del user[key]
jsonSave(f"data/users/{userid}.json", user)
except KeyError:
pass