summaryrefslogtreecommitdiff
path: root/scripts/emotes.js
blob: 96bc103a5d544c8d3fa1faf513310a5ffb6177b7 (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
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`;
            }
        });
}