-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
43 lines (33 loc) · 989 Bytes
/
index.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
'use strict'
require('dotenv').config({path: '../.env'});
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
});
const path = require('path');
const { mongoose } = require(path.join(__dirname, 'src', 'db'))
const commands = [
'balance',
'tip',
'reaction',
'rain',
'help',
'notification',
'tl_all',
'member'
]
if(commands && commands.length > 0){
const { bot, controller } = require(path.join(__dirname, 'src', 'bot'))
const { SLACK_WEBHOOK_URL } = require("./config");
bot.startRTM((err) => {
if (err) {
throw new Error(err);
}
})
bot.configureIncomingWebhook({
url: SLACK_WEBHOOK_URL
})
controller.on('rtm_reconnect_failed',function(bot) {
console.log('\n\n*** '+moment().format() + ' ** Unable to automatically reconnect to rtm after a closed conection.')
})
commands.forEach( (command, index)=> require(`./src/handlers/${command}`)(controller) );
}