-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.js
37 lines (33 loc) · 1.11 KB
/
functions.js
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
var fs = require("fs");
module.exports = {
reply: function(message, content) {
message.channel.send(content)
.catch(err => {
console.log(err)
});
},
// If the env variable is not set, use a default variable
setEnv: function(envVariable, defaultVariable) {
return Object.is(envVariable, undefined) ? defaultVariable : envVariable;
},
saveJson: function(file, data) {
fs.writeFile("storage/" + file + ".json", JSON.stringify(data), "utf8", (err) => {
if (err) {
console.log("There was an error saving the file. Error: " + err);
pushReply(message, "There was an error saving the " + file + " file. Please contact the bot owner.");
}
});
},
verifyJson: function(json) {
try {
JSON.stringify(json);
} catch (e) {
return false;
}
return true;
}
}
// var setEnv = function(envVariable, defaultVariable) {
// return Object.is(envVariable, undefined) ? defaultVariable : envVariable;
// }
// exports.setEnv = setEnv;