summaryrefslogtreecommitdiff
path: root/scripts/emotes.js
blob: 84f99011af50813c398e96d1d40e29f3962d1855 (plain)
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
function getBetterTTVChannelEmotes(twitchId, emotes) {
    return fetch(`https://api.betterttv.net/3/cached/users/twitch/${twitchId}`)
        .then((r) => r.json())
        .then((json) => {
            if ("message" in json) {
                addSystemMessage(`${json["message"]} (BetterTTV)`);
                return;
            }
            
            for (const e of [...json["channelEmotes"], ...json["sharedEmotes"]]) {
                emotes[e["code"]] = `https://cdn.betterttv.net/emote/${e["id"]}/1x.webp`;
            }
        });
}

function getBetterTTVGlobalEmotes(emotes) {
    return fetch(`https://api.betterttv.net/3/cached/emotes/global`)
        .then((r) => r.json())
        .then((json) => {
            for (const e of json) {
                emotes[e["code"]] = `https://cdn.betterttv.net/emote/${e["id"]}/1x.webp`;
            }
        });
}

function get7TVChannelEmotes(twitchId, emotes) {
    return fetch(`https://7tv.io/v3/users/twitch/${twitchId}`)
        .then((r) => r.json())
        .then((json) => {
            if ("error" in json) {
                addSystemMessage(`${json["error"]} (7TV)`);
                return;
            }
            
            for (const e of json["emote_set"]["emotes"]) {
                emotes[e["name"]] = `https://cdn.7tv.app/emote/${e["id"]}/1x.webp`;
            }
        });
}

function get7TVGlobalEmotes(emotes) {
    return fetch(`https://7tv.io/v3/emote-sets/global`)
        .then((r) => r.json())
        .then((json) => {
            for (const e of json["emotes"]) {
                emotes[e["name"]] = `https://cdn.7tv.app/emote/${e["id"]}/1x.webp`;
            }
        });
}