-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
59 lines (49 loc) · 1.2 KB
/
index.ts
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
49
50
51
52
53
54
55
56
57
58
59
/* eslint-disable @typescript-eslint/ban-ts-comment */
'use strict';
import * as http from 'http';
import * as codeOfConduct from './commands/codeOfConduct';
// @ts-ignore
import diceRoller from './commands/diceRoller';
// @ts-ignore
import newsFeed from './commands/newsFeed';
// @ts-ignore
import voiceChannelManager from './commands/voiceChannelManager';
import BotWrapper from './lib/BotWrapper';
// @ts-ignore
import ftl from './lib/ftl';
let pingCount = 0;
// Heroku requires a port to be bound
http
.createServer((_, res) => {
res.end('hello');
})
.listen(process.env.PORT || 5050);
const TOKEN = process.env.TOKEN;
if (!TOKEN) {
throw new Error('Configuration error, TOKEN is required.');
}
const bot = new BotWrapper(
TOKEN,
{
restMode: true,
},
{
owner: 'Errolyn',
prefix: '!',
},
);
bot.on('ready', () => {
console.log(`Ready at ${new Date().toLocaleString()}!`);
});
bot.on('error', (err: unknown) => {
console.log(err);
});
bot.registerCommand('ping', () => {
pingCount++;
return ftl('ping-response', { pingCount });
});
newsFeed.register({ bot });
diceRoller.register({ bot });
codeOfConduct.register({ bot });
voiceChannelManager.register({ bot });
bot.connect();