forked from Carbowix/Cleve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (36 loc) · 1.26 KB
/
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
43
44
const Discord = require('discord.js');
const {
token,
status
} = require('./misc/config.json');
const client = new Discord.Client({
disableEveryone: true,
disabledEvents: ['CHANNEL_PINS_UPDATE', 'GUILD_BAN_ADD', 'GUILD_BAN_REMOVE', 'RELATIONSHIP_ADD', 'RELATIONSHIP_REMOVE']
});
client.util = require('./util');
client.on('warn', err => console.warn('[WARNING]', err));
client.on('error', err => console.error('[ERROR]', err));
client.on('disconnect', () => {
console.warn('Disconnected!')
process.exit(0);
});
client.on('uncaughtException', (err) => {
console.log('Uncaught Exception: ' + err)
process.exit(1)
});
client.on('message', (msg) => {
if (msg.author.bot) return;
if (msg.guild) {
if (msg.content.startsWith(`<@${msg.client.user.id}>`) || msg.content.startsWith(`<@!${msg.client.user.id}>`)) {
client.util.handleTalk(msg);
}
}
});
client.on('ready', () => {
client.util.handleStatus(client, status);
console.log('[CLEVE] Started and ready to chat!');
});
process.on('unhandledRejection', (reason, promise) => {
console.log('[FATAL] Possibly Unhandled Rejection at: Promise ', promise, ' reason: ', reason.message);
});
client.login(token);