-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot.js
48 lines (31 loc) · 1.04 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
const Discord = require('discord.js');
const express = require('express')
const events = require('./src/events')
const client = new Discord.Client();
const PORT = process.env.PORT || 80; // Let Heroku set the port.
// THIS MUST BE THIS WAY
client.on('ready', () => {
console.log('I am ready!');
});
client.on('message', message => {
console.log(message.content)
if (message.isMentioned(client.user)) {
events.handlers['appMention'](message)
}
else {
events.handlers['message'](message)
}
});
client.login(process.env.DISCORD_TOKEN);//BOT_TOKEN is the Client Secret
const bootstrap = ( options = {}) => {
// Allow alternative implementations of both Express and Slack to be passed in.
const server = options.express || express();
return server.listen( PORT, () => {
console.log( 'Listening on port ' + PORT + '.' );
});
}; // Bootstrap.
// If module was called directly, bootstrap now.
if ( require.main === module ) {
bootstrap();
}
module.exports = bootstrap;