fix: Added a check for missing config files. Added FileHandler class.

This commit is contained in:
2025-06-06 16:43:48 +02:00
parent 93183799af
commit aac85e3679
12 changed files with 119 additions and 48 deletions

View File

@@ -37,8 +37,21 @@ class Settings {
}
public reloadSettings() {
this.settings = JSON.parse(readFileSync('./config/options.json', 'utf-8'))
this.optionsToFlags()
try {
this.settings = JSON.parse(readFileSync('./config/options.json', 'utf-8'))
this.optionsToFlags()
} catch (error) {
if (error instanceof Error) {
if ('code' in error) {
if (error.code == "ENOENT") {
console.warn("WARNING: Capability file 'options.json' not found, enabling all modules.")
console.info("INFO: This warning will dissapear in future release of this program.")
this.settings = { clean: true, groups: true, key: true, menu: true, news: true, notif: true }
this.optionsToFlags()
}
}
}
}
}
public get flags() : number {