-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
100 lines (81 loc) · 2.8 KB
/
main.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
//NPM Node modules
const Discord = require("discord.js"),
m = require("chalk"),
//Design the client
client = new Discord.Client(),
//Local files
func = require('./func/propFunctions'),
log = require('./enum/consoleLogging'),
regToken = /[\w\d]{24}\.[\w\d]{6}\.[\w\d-_]{27}/g;
func.constructConfig('./config.json');
setTimeout(function(){
const config = require("./config.json");
const active = new Map();
require('./util/eventLoader')(client, active);
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.emojisByName = new Discord.Collection();
client.commandCategories = ['Standard','Music','Games','Admin','RPG']
client.commandCategoriesCollection = new Discord.Collection();
require('./util/commandLoader')(client);
client.on('warn', e => {
console.log(m.bgYellow(e.replace(regToken, 'that was redacted')));
});
client.on('error', e => {
console.log(m.bgRed(e.replace(regToken, 'that was redacted')));
});
/*
client.on('rateLimit', e => {
log.warning('RATE LIMIT HIT!');
console.dir(e);
});
*/
var logon_try = client.login(config.token);
logon_try
.catch( (error) => {
// ETIMEDOUT
// ENOTFOUND
if(error.code == 'ETIMEDOUT' || error.code == 'ENOTFOUND') {
return log.error(error);
}
console.log('You need to setup the config file before proceeding to run this bot');
process.exit();
});
/////////////
// #### //
// Modules //
// #### //
/////////////
/*
if(config['twitter_module'].enable_twitter_module){
try {
var twitter_module_interval = setInterval(function(){
require('./modules/twitterModule.js')(client)
.catch(error => {
log.error(error);
})
},60000*5);
} catch(error) {
log.error(error);
}
}
*/
let delayTime = 60000;
if(config['twitch_module'].enable_twitch_module){
try {
var twitch_module_interval = setInterval(function(){
require('./modules/twitchModule.js')(client).
then(()=>{
delayTime = 60000;
})
.catch(error => {
log.error('[Twitch Module] '+error);
delayTime = 600000;
})
},delayTime);
} catch(error) {
log.error('[Twitch Module] '+error);
}
}
//require('./util/mysqlConn');
},25);