-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.js
More file actions
80 lines (77 loc) · 2.62 KB
/
Copy pathdatabase.js
File metadata and controls
80 lines (77 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var fs = require("fs");
function database() {
this.groups = require("./db/groups.json");
this.messages = require("./db/messages.json");
this.channels = require("./db/channels.json");
this.images = require("./db/images.json");
this.beatmaps = require("./db/beatmaps.json");
this.bans = require("./db/bans.json");
this.nsfwChannels = require("./db/nsfwChannels.json");
this.saveConfig = function(args) {
switch(args){
case "groups":
fs.writeFile("db/groups.json", JSON.stringify(this.groups), function(error) {
if (error) {
console.error("write error: " + error.message);
}
});
break;
case "messages":
fs.writeFile("db/messages.json", JSON.stringify(this.messages, null, '\t').replace(/`/g, '\u200B`'), function(error) {
if (error) {
console.error("write error: " + error.message);
}
});
break;
case "channels":
fs.writeFile("db/channels.json", JSON.stringify(this.channels), function(error) {
if (error) {
console.error("write error: " + error.message);
}
});
break;
case "beatmaps":
fs.writeFile("db/beatmaps.json", JSON.stringify(this.beatmaps, null, '\t').replace(/`/g, '\u200B`'), function(error) {
if (error) {
console.error("write error: " + error.message);
}
});
break;
case "bans":
fs.writeFile("db/bans.json", JSON.stringify(this.bans, null, '\t').replace(/`/g, '\u200B`'), function(error) {
if (error) {
console.error("write error: " + error.message);
}
});
break;
case "nsfwChannels":
fs.writeFile("db/nsfwChannels.json", JSON.stringify(this.nsfwChannels, null, '\t').replace(/`/g, '\u200B`'), function(error) {
if (error) {
console.error("write error: " + error.message);
}
});
break;
}
}
this.isUserInGroup = function (uid, group) {
if(!this.groups || !this.groups[group]) {
return false;
}
for(var i = 0; i < this.groups[group].length; i++) {
if(this.groups[group][i] == uid) {
return true;
}
}
return false;
}
this.isUserBanned = function (uid) {
if(!this.bans || !this.bans[uid]) {
return false;
}
if(this.bans[uid]){
return false;
}
return false;
}
}
module.exports = database;