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 |
|
console.log(`ENV: ${process.env.SUDO_PREFIX}`); |
22 |
|
this.configPath = path.resolve(process.env.SUDO_PREFIX ?? this.client.rootdir, "config", "config.json"); |
23 |
this.load(); |
this.load(); |
24 |
} |
} |
25 |
|
|
26 |
load() { |
load() { |
27 |
fs.readFile(path.resolve(__dirname, this.client.rootdir, "config", "config.json"), (err, data) => { |
fs.readFile(this.configPath, (err, data) => { |
28 |
if (err) { |
if (err) { |
29 |
console.log(err); |
console.log(err); |
30 |
} |
} |
34 |
} |
} |
35 |
|
|
36 |
write() { |
write() { |
37 |
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); |
38 |
} |
} |
39 |
|
|
40 |
get(key: string) { |
get(key: string) { |