-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (38 loc) · 1 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
45
46
47
48
49
50
51
const tmi = require('tmi.js');
require('dotenv').config();
const options = {
options: {
debug: false
},
connection: {
cluster: 'aws',
reconnect: true,
},
identity: {
username: process.env.TMI_USERNAME,
password: process.env.TMI_PASSWORD,
},
channels: [
'dishark'
],
};
const client = new tmi.Client(options);
client.connect();
client.on('connected', (address, port) => {
// client.say('dishark', 'Bot Runeterra online!');
console.log('Bot tá on');
})
client.on('message', async (channel, user, message, self) => {
if(self) return;
const command = message.split(' ').shift() ?? message;
const args = message.split(' ').splice(1);
if(! command.startsWith('!')) {
return;
}
try {
const output = await require(`./commands/${command.substr(1)}`)(args);
client.say(channel, output);
} catch (e) {
// comando não foi encontrado, não precisa de feedback no chat
}
});