-
Notifications
You must be signed in to change notification settings - Fork 1
/
emotion.js
44 lines (39 loc) · 1.13 KB
/
emotion.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
#!/usr/bin/env node
const Discord = require('discord.io');
const logger = require('winston');
const mongoose = require('mongoose');
// Load routers
const actionRouter = require('./routers/action_router');
// DB Config
const db = require('./config/database');
// Map global promise - get rid of warning
mongoose.Promise = global.Promise;
// Connect to mongoose
mongoose.connect(db.mongoURI, {
useMongoClient: true
})
.then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err));
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
const dc = require('./config/discord');
const bot = new Discord.Client({
token: dc.discordToken,
autorun: true
});
bot.on('ready', function (evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userId, channelId, message, evt) {
actionRouter(bot, channelId, message, evt);
});
bot.on('disconnect', function(errMsg, code) {
console.log(errMsg);
});