Conditions | 5 |
Total Lines | 16 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import json |
||
25 | @lru_cache() |
||
26 | def get_settings(key: str): |
||
27 | """Get the selected key from the settings file""" |
||
28 | try: |
||
29 | with open("server_files/bot_settings.json", "r", encoding="UTF-8") as f: |
||
30 | _json = json.load(f) |
||
31 | return _json[key] |
||
32 | except FileNotFoundError: |
||
33 | with open("server_files/bot_settings.json", "w", encoding="UTF-8") as f: |
||
34 | json.dump(template_json, f, indent=2) |
||
35 | print("No bot_settings.json found. One has been created, please populate it and restart") |
||
36 | exit(1) |
||
37 | except KeyError: |
||
38 | print(f"Incomplete bot_settings.json found\n" |
||
39 | f"Check your file") |
||
40 | exit(1) |
||
41 |