-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
27 lines (22 loc) · 1.18 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
const tmi = require("tmi.js");
const fetch = require("node-fetch");
process.on('unhandledRejection', error => console.log(error));
process.on('uncaughtException', error => console.log(error));
const client = new tmi.client(require("./config.json").twitch);
const { host, port, socket } = require("./config.json");
client.connect().then(() => {
console.log("[INFO] Connected to Twitch!");
client.on("message", async (channel, tags, message, self) => {
const prefix = "!"
if (!message.startsWith(prefix)) return;
const args = message.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command == "np" || command == "nowplaying") {
const response = await fetch(`${host}:${port}/${socket}`).then(res => res.json());
client.say(channel, `@${tags.username}, Beatmap: https://osu.ppy.sh/beatmapsets/${response.menu.bm.set}#/${response.menu.bm.id} | Mods: ${response.menu.mods.str}`);
} else if (command == "skin") {
const response = await fetch(`${host}:${port}/${socket}`).then(res => res.json());
client.say(channel, `@${tags.username}, Skin: ${response.settings.folders.skin}`);
}
});
});