-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (28 loc) · 988 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
const Discord = require('discord.js');
var logger = require('./lib/logger');
var commands = require('./lib/commands');
const token = process.env.BOAT_TOKEN;
var client = new Discord.Client();
client.on('ready', function() {
logger("bot", "Ready!");
client.user.setGame("Sailing | +hello")
});
client.on('message', function(message) {
var command = commands.find(function(element){
if (element.regex.exec(message.content)) return true; else return false;
});
if (command) {
command.method(message, command.regex.exec(message.content), commands); //1: message, 2: args, 3: other commands
}
});
client.login(token);
process.on('SIGINT', function() {
logger("bot", "Disconnecting...");
client.destroy().then(function() {
logger("bot", "Disconnected.");
process.exit();
}).catch(function() {
logger("bot", "Failed to properly disconnect.");
process.exit();
});
});