This repository has been archived by the owner on Nov 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.js
113 lines (98 loc) · 2.37 KB
/
basic.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
module.exports.init = fs => {
fs.readdir(__dirname + "/commands/", {}, (err, file) => {
if (err) console.error(err);
var jsfile = file.filter(f => f.split(".").pop() === "js");
jsfile.forEach((f, i) => {
var props = require(__dirname + "/commands/" + f);
console.log(f + " loaded!");
client.commands.set(f.replace(".js", ""), props);
if (props.init) {
props.init();
}
});
});
fs.readdir(__dirname + "/extra/", {}, (err, file) => {
if (err) console.error(err);
var jsfile = file.filter(f => f.split(".").pop() === "js");
jsfile.forEach((f, i) => {
var props = require(__dirname + "/extra/" + f);
console.log(f + " loaded!");
client.extra.set(f.replace(".js", ""), props);
props.init();
});
});
setInterval(() => {
jsonfile
.writeFile(__dirname + "/config.json", config)
.then(res => {
console.log("Saved config");
})
.catch(error => console.error(error));
}, 1000 * 10);
};
global.getConfig = function(g) {
if (!g) return;
var c = config.guilds.find(x => x.id == g.id);
if (c == undefined) {
c = config.guilds[config.guilds.push(new guildConfig(guild)) - 1];
} else {
client.commands.forEach((x, i) => {
if (x.settings) {
if (!c.commands[i]) {
c.commands[i] = x.settings;
}
}
});
client.extra.forEach((x, i) => {
if (x.settings) {
if (!c.extra[i]) {
c.extra[i] = x.settings;
}
}
});
}
return c;
};
global.send = function(channel, type, title, text, fields, thumbnail) {
var color;
type = type.toLowerCase();
switch (type) {
case "help":
title = "Help: " + title;
color = 0x8900f2;
break;
case "error":
title = "Error: " + title;
color = 0xdd2c2c;
break;
case "success":
title = "Success: " + title;
color = 0x05af10;
break;
case "info":
title = "Info: " + title;
color = 0x0087ff;
break;
default:
color = 0x707070;
break;
}
var message = new Discord.RichEmbed()
.setColor(color)
.setTitle(title)
.setThumbnail(thumbnail)
.setColor(color)
.setDescription(text)
.setAuthor(
`${channel.guild ? channel.guild.name : client.user.username}`,
channel.guild ? channel.guild.iconURL : client.user.displayAvatarURL
)
.setFooter(
client.user.username + " Bot coded by NaCl-y#4400 & Flam3rboy#5979",
client.user.displayAvatarURL
);
if (fields) {
message.fields = fields;
}
return channel.send(message);
};