/[sudobot]/trunk/src/Config.js
ViewVC logotype

Contents of /trunk/src/Config.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (show annotations)
Mon Jul 29 17:28:11 2024 UTC (8 months ago) by rakin
File MIME type: text/javascript
File size: 814 byte(s)
Added base commands
1 const path = require("path");
2 const fs = require("fs");
3
4 class Config {
5 constructor() {
6 this.props = {};
7 this.load();
8 }
9
10 load() {
11 fs.readFile(path.resolve(__dirname, app.rootdir, "config", "config.json"), (err, data) => {
12 if (err) {
13 console.log(err);
14 }
15
16 this.props = JSON.parse(data);
17 });
18 }
19
20 write() {
21 fs.writeFile(path.resolve(__dirname, app.rootdir, "config", "config.json"), JSON.stringify(this.props), (err) => {
22 console.log(err);
23 });
24 }
25
26 get(key) {
27 return typeof this.props[app.msg.guild.id] === 'object' ? this.props[app.msg.guild.id][key] : null;
28 }
29
30 set(key, value) {
31 this.props[app.msg.guild.id][key] = value;
32 }
33 }
34
35 module.exports = Config;

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26