| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import json |
||
| 2 | from functools import lru_cache |
||
| 3 | |||
| 4 | template_json = { |
||
| 5 | "token": "None", |
||
| 6 | "git_token": "None", |
||
| 7 | "guild": [881161915689209936], |
||
| 8 | "ADMIN": "None", |
||
| 9 | "MOD_ROLES": [], |
||
| 10 | "CH_ADMIN_POSTING": "None", |
||
| 11 | "CH_ROLE_REQUEST": "None", |
||
| 12 | "CH_TOTAL_MEMBERS": "None", |
||
| 13 | "CH_NIGHTMARE_KILLED": "None", |
||
| 14 | "CH_LEADERBOARDS": "None", |
||
| 15 | "CH_TEMP": "None", |
||
| 16 | "CH_COMMON": "None", |
||
| 17 | "CH_LOGS": "None", |
||
| 18 | "CH_VOICE_CHAT": "None", |
||
| 19 | "CH_DISCUSSION_EN": "None", |
||
| 20 | "CAT_SPOTTING": "None", |
||
| 21 | "EXCEL_ID": "None", |
||
| 22 | "DB_U": "None", |
||
| 23 | "DB_P": "None" |
||
| 24 | } |
||
| 25 | |||
| 26 | |||
| 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 |