Small improvements

This commit is contained in:
DJj123dj
2024-09-01 20:55:50 +02:00
parent 4e030bf95b
commit c1c80fc04d
15 changed files with 117 additions and 138 deletions
+6 -4
View File
@@ -67,8 +67,10 @@ export class ODConfigManager extends ODManager<ODConfig> {
* You will only use this class if you want to create your own config implementation (e.g. `yml`, `xml`,...)!
*/
export class ODConfig extends ODManagerData {
/**The full path to this config with extension */
/**The name of the file with extension. */
file: string = ""
/**The path to the file relative to the main directory. */
path: string = ""
/**An object/array of the entire config file! Variables inside it can be edited while the bot is running! */
data: any = undefined
}
@@ -87,9 +89,9 @@ export class ODJsonConfig extends ODConfig {
constructor(id:ODValidId, file:string, customPath?:string){
super(id)
try {
const filename = (file.endsWith(".json")) ? file : file+".json"
this.file = customPath ? nodepath.join("./",customPath,filename) : nodepath.join("./config/",filename)
this.data = JSON.parse(fs.readFileSync(this.file).toString())
this.file = (file.endsWith(".json")) ? file : file+".json"
this.path = customPath ? nodepath.join("./",customPath,this.file) : nodepath.join("./config/",this.file)
this.data = JSON.parse(fs.readFileSync(this.path).toString())
}catch(err){
process.emit("uncaughtException",err)
throw new ODSystemError("Config \""+nodepath.join("./",customPath ?? "./config/",file)+"\" doesn't exist!")