-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (44 loc) · 970 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
const axios = require('axios');
const tmi = require('tmi.js');
const dotenv = require('dotenv');
dotenv.config();
const {
CHANNEL: channel,
GIST: gist,
PASSWORD: password,
USERNAME: username,
WAIT_TIME: waitTime = 1500,
} = process.env;
const options = {
options: {
debug: true,
},
connection: {
reconnect: true,
secure: true,
},
identity: {
username,
password,
},
channels: [channel],
};
const client = new tmi.Client(options);
client.connect();
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
const massCommand = async () => {
const { data } = await axios.get(gist);
const commandArray = data.split(/\n/);
for (const cmd of commandArray) {
client.say(channel, cmd);
await sleep(parseInt(waitTime, 10));
}
process.exit(1);
};
client.on('connected', () => massCommand());