/[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 360 by rakin, Mon Jul 29 17:29:46 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            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              }              }
# Line 31  export class Config { Line 33  export class Config {
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) {

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26