-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
172 lines (160 loc) · 5.59 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
const tmi = require('tmi.js');
require('dotenv').config()
const client = new tmi.Client({
connection: {
reconnect: true,
secure: true
},
options: {
clientId: process.env.clientId,
},
identity: {
username: process.env.botUsername,
password: process.env.botPassword
},
channels: [ 'AndrewDragonCh' ]
});
client.on("connecting", (address, port) => {
console.log(`Connecting to ${address}:${port}`)
});
client.connect()
.then((data) => {
console.log(`Connected to ${data[0]}:${data[1]}`)
}).catch((err) => {
console.log(`Failed to connect. ${err}`)
});
client.on('message', (channel, tags, message, self) => {
if(self || !message.startsWith('!')) return;
const args = message.slice(1).split(' ');
const command = args.shift().toLowerCase();
if(command === 'ping') {
client.ping()
.then((data) => {
client.say(channel, `Ping: ${data*1000}ms`)
console.log(`Ping command succeeded.`)
}).catch((err) => {
console.log(`Failed to execute ping command. ${err}`)
});
}
if(command === 'specs' || command === 'pc') {
client.say(channel, `@${tags.username} https://pcpartpicker.com/user/AndrewDragonCh/saved/QR24gs`)
.then(() => {
console.log(`Specs command succeeded.`)
}).catch((err) => {
console.log(`Specs command failed. ${err}`)
});
}
if(command === 'headphones' || command === 'headset') {
client.say(channel, `@${tags.username} Razer Nari Essentials or Apple AirPods Pro 2`)
.then(() => {
console.log(`Headphones command succeeded.`)
}).catch((err) => {
console.log(`Headphones command failed. ${err}`)
});
}
if(command === 'mouse') {
client.say(channel, `@${tags.username} Razer Viper V2 Pro`)
.then(() => {
console.log(`Mouse command succeeded.`)
}).catch((err) => {
console.log(`Mouse command failed. ${err}`)
});
}
if(command === 'keyboard' || command === 'kb') {
client.say(channel, `@${tags.username} Corsair K65 Mini in White.`)
.then(() => {
console.log(`Keyboard command succeeded.`)
}).catch((err) => {
console.log(`Keyboard command failed. ${err}`)
});
}
if(command === 'monitor') {
client.say(channel, `@${tags.username} Main is an Acer XF273 1080p 165hz. Second and third are both 1080p 60hz.`)
.then(() => {
console.log(`Monitor command succeeded.`)
}).catch((err) => {
console.log(`Monitor command failed. ${err}`)
});
}
if(command === 'mousepad') {
client.say(channel, `@${tags.username} HyperX Extended Mousepad`)
.then(() => {
console.log(`Mousepad command succeeded.`)
}).catch((err) => {
console.log(`Mousepad command failed. ${err}`)
});
}
if(command === 'help') {
client.say(channel, `@${tags.username} I need to remake this...`)
.then(() => {
console.log(`Help command succeeded.`)
}).catch((err) => {
console.log(`Help command failed. ${err}`)
});
}
});
client.on("clearchat", (channel) => {
client.say(channel, `Chat has been cleared. Naughty chat.`)
.then(() => {
console.log(`Chat has been cleared and notified.`)
}).catch((err) => {
console.log(`Chat has been cleared but not notified. ${err}`)
});
});
client.on("raided", (channel, username, viewers) => {
client.say(channel, `Thanks @${username} for the ${viewers} viewer raid! Hope you had a good stream!`)
.then((data) => {
console.log(`Successfully thanked ${username} for raiding with ${viewers}. ${data}`)
}).catch((err) => {
console.log(`Failed to thank ${username} for raiding with ${viewers}. ${err}`)
});
});
client.on("slowmode", (channel, enabled, length) => {
if(enabled === true) {
client.say(channel, `Slow mode has been set to ${length} seconds. Be good chat!`)
.then(() => {
console.log(`Slow mode has been set to ${length} seconds and chat notified.`)
}).catch((err) => {
console.log(`Slow mode has been set to ${length} seconds but chat was not notified. ${err}`)
});
} else if(enabled === false) {
client.say(channel, `Slow mode has been disabled. Be good chat!`)
.then(() => {
console.log(`Slow mode has been disabled and chat notified.`)
}).catch((err) => {
console.log(`Slow mode has been disabled but chat was not notified. ${err}`)
});
} else {
client.say(channel, `Slow mode has either been enabled or disabled, but I'm not sure which one...`)
.then(() => {
console.log(`Slow mode has either been enabled or disabled and chat notified.`)
}).catch((err) => {
console.log(`Slow mode has either been enabled or disabled but chat was not notified. ${err}`)
});
}
});
client.on("subscription", (channel, username, method, message, userstate) => {
client.say(channel, `Thanks @${username} for subscribing!`)
.then((data) => {
console.log(`Successfully thanked ${username} for subbing. ${data}`)
}).catch((err) => {
console.log(`Failed to thank ${username} for subbing. ${err}`)
});
});
client.on("whisper", (from, userstate, message, self) => {
if (self) return;
client.whisper(from, `I don't listen to whisperers. If you want me, speak in chat.`)
.then((data) => {
console.log(`Harassed a whisperer.`)
}).catch((err) => {
console.log(`Whisperer got away... ${err}`)
});
});
client.on("ping", () => {
client.ping()
.then((data) => {
console.log(`Successfully responded to Twitch Ping. ${data*1000}`)
}).catch((err) => {
console.log(`Failed to respond to Twitch Ping. ${err}`)
});
});