/[sudobot]/trunk/src/client/Config.ts
ViewVC logotype

Diff of /trunk/src/client/Config.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 359 by rakin, Mon Jul 29 17:29:46 2024 UTC revision 362 by rakin, Mon Jul 29 17:29:47 2024 UTC
# Line 14  export type configContainer = { Line 14  export type configContainer = {
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              }              }
# Line 31  export class Config { Line 34  export class Config {
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) {

Legend:
Removed from v.359  
changed lines
  Added in v.362

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26