14 |
export class Config { |
export class Config { |
15 |
props: configContainer = {}; |
props: configContainer = {}; |
16 |
client: DiscordClient; |
client: DiscordClient; |
17 |
|
configPath: string; |
18 |
|
|
19 |
constructor(client: DiscordClient) { |
constructor(client: DiscordClient) { |
20 |
this.client = client; |
this.client = client; |
21 |
|
this.configPath = path.resolve(process.env.SUDO_PREFIX ?? this.client.rootdir, "config", "config.json"); |
22 |
this.load(); |
this.load(); |
23 |
} |
} |
24 |
|
|
25 |
load() { |
load() { |
26 |
fs.readFile(path.resolve(__dirname, this.client.rootdir, "config", "config.json"), (err, data) => { |
fs.readFile(this.configPath, (err, data) => { |
27 |
if (err) { |
if (err) { |
28 |
console.log(err); |
console.log(err); |
29 |
} |
} |
33 |
} |
} |
34 |
|
|
35 |
write() { |
write() { |
36 |
fs.writeFile(path.resolve(__dirname, this.client.rootdir, "config", "config.json"), JSON.stringify(this.props, undefined, ' '), () => null); |
fs.writeFile(this.configPath, JSON.stringify(this.props, undefined, ' '), () => null); |
37 |
} |
} |
38 |
|
|
39 |
get(key: string) { |
get(key: string) { |