summaryrefslogtreecommitdiff
path: root/scripts/badges.js
blob: 3f8b8daf0d0f0aaf4dfe2a793e8a43024ca26d02 (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 getTwitchBadges(name, badges) {
    const bb = [];
    fetch("https://api.ivr.fi/v2/twitch/badges/global")
        .then((r) => r.json())
        .then((b) => {
            for (const badge of b) {
                for (const version of badge["versions"]) {
                    badges[`${badge["set_id"]}/${version["id"]}`] = version["image_url_1x"];
                }
            }
            addSystemMessage("Loaded Twitch global badges.");
        });
    
    fetch(`https://api.ivr.fi/v2/twitch/badges/channel?login=${name}`)
        .then((r) => r.json())
        .then((b) => {
            for (const badge of b) {
                for (const version of badge["versions"]) {
                    badges[`${badge["set_id"]}/${version["id"]}`] = version["image_url_1x"];
                }
            }
            addSystemMessage("Loaded Twitch channel badges.");
        });
}