-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
70 lines (57 loc) · 1.71 KB
/
bot.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
import { client as _client } from "tmi.js";
const opts = {
identity: {
username: process.env.USERNAME,
password: process.env.OAUTH_TOKEN,
},
channels: ["onthepixel"],
};
const client = new _client(opts);
client.on("message", onMessageHandler);
client.on("connected", onConnectedHandler);
client.on("follow", onFollowHandler);
client.on("subscription", onSubscriptionHandler);
client.connect();
function onMessageHandler(target, context, msg, self) {
if (self) {
return;
}
const commandName = msg.trim();
if (commandName === "!discord" || commandName === "!dc") {
client.say(
target,
`Join our Discord server: https://discord.onthepixel.net`
);
}
if (commandName === "!website" || commandName === "!web") {
client.say(target, `Check out our website: https://onthepixel.net`);
}
if (commandName === "!socials") {
client.say(
target,
`Twitter/X: https://x.com/onthepixelnet\nInstagram: https://www.instagram.com/onthepixel_net/`
);
}
if (commandName === "!help" || commandName === "!commands") {
client.say(
target,
`Discord: !discord, !dc\nWeb: !website, !web\nSocial: !socials\nHelp: !help, !commands`
);
}
}
function onConnectedHandler(addr, port) {
console.log(`* Connected to ${addr}:${port}`);
}
function onFollowHandler(channel, username) {
client.say(channel, `Thank you for following, ${username}!`);
}
function onSubscriptionHandler(channel, username, method, message, userstate) {
client.say(channel, `Thank you for subscribing, ${username}!`);
}
function sendDiscordMessage() {
client.say(
"onthepixel",
"Join our Discord server: https://discord.onthepixel.net"
);
}
setInterval(sendDiscordMessage, 600000);