/warn and /warnings commands

This commit is contained in:
Profitroll
2022-11-13 13:40:49 +01:00
parent 359f08c021
commit 76d7d7f4c6
3 changed files with 98 additions and 35 deletions

View File

@@ -20,7 +20,6 @@ def jsonLoad(filename):
except FileNotFoundError:
logWrite(f"Could not load json file {filename}: file does not seem to exist!\n{print_exc()}")
raise
file.close()
return output
def jsonSave(contents, filename):
@@ -28,7 +27,6 @@ def jsonSave(contents, filename):
try:
with open(filename, "w", encoding='utf8') as file:
file.write(dumps(contents, ensure_ascii=False, indent=4))
file.close()
except Exception as exp:
logWrite(f"Could not save json file {filename}: {exp}\n{print_exc()}")
return
@@ -44,7 +42,8 @@ def configSet(key: str, value, *args: str, file: str = "config"):
"""
if file == "config":
filepath = ""
if this_dict["debug"]:
this_dict = jsonLoad(f"{filepath}{file}.json")
if this_dict["debug"] is True:
try:
this_dict = jsonLoad("config_debug.json")
file = "config_debug"
@@ -52,7 +51,7 @@ def configSet(key: str, value, *args: str, file: str = "config"):
print("Debug mode is set but config_debug.json is not there! Falling back to config.json", flush=True)
else:
filepath = f"data{sep}users{sep}"
this_dict = jsonLoad(f"{filepath}{file}.json")
this_dict = jsonLoad(f"{filepath}{file}.json")
string = "this_dict"
for arg in args:
string += f'["{arg}"]'
@@ -79,7 +78,7 @@ def configGet(key: str, *args: str, file: str = "config"):
except FileNotFoundError:
print("Config file not found! Copy config_example.json to config.json, configure it and rerun the bot!", flush=True)
exit()
if this_dict["debug"]:
if this_dict["debug"] is True:
try:
this_dict = jsonLoad("config_debug.json")
except FileNotFoundError: