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