-
Notifications
You must be signed in to change notification settings - Fork 10
/
bot.js
37 lines (30 loc) · 876 Bytes
/
bot.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
/*
Entry point for tech support queue bot
License: MIT
Copyright 2017 BitQuote
*/
// Package imports
const Discord = require('discord.js');
const winston = require('winston');
const requireDir = require('require-dir');
// Module imports
const Database = require('./modules/database.js');
const config = require('./config');
// Event handlers
const events = requireDir('./events');
// Initialize client
const bot = new Discord.Client();
const token = config.token;
// Attempt DB setup
const db = new Database();
db.init()
.then(() => {
// Log into Discord
bot.login(token);
})
.catch(winston.error);
// Define event handlers
bot.on('ready', () => events.ready(db));
bot.on('message', message => events.message(message, db));
bot.on('messageDelete', message => events.messageDelete(message, db));
bot.on('guildCreate', guild => events.guildCreate(guild, db));