Skip to content

Commit

Permalink
add the known cheersmotes loader function
Browse files Browse the repository at this point in the history
  • Loading branch information
BarryCarlyon committed May 8, 2024
1 parent b46ca10 commit 5201f36
Show file tree
Hide file tree
Showing 2 changed files with 272 additions and 237 deletions.
36 changes: 35 additions & 1 deletion eventsub/websockets/web/activity_feed/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,38 @@ function buildFromFragments(chat, fragments) {
console.error(fragments[x]);
}
}
}
}

async function loadCheermotes(broadcaster_id) {
let url = new URL('https://api.twitch.tv/helix/bits/cheermotes');
url.search = new URLSearchParams([['broadcaster_id', broadcaster_id]]).toString();

let bitsRequest = await fetch(
url,
{
"headers": {
"Client-ID": client_id,
"Authorization": `Bearer ${access_token}`
}
}
);
if (bitsRequest.status != 200) {
return;
}
let { data } = await bitsRequest.json();

data.forEach(cheermote => {
let { prefix, tiers } = cheermote;
if (tiers && tiers.length > 0) {
knownCheermotes[prefix] = {};

tiers.forEach(tier => {
let { can_cheer, id, images } = tier;
if (can_cheer) {
let image = images.dark.animated["1.5"];
knownCheermotes[prefix][id] = image;
}
});
}
});
}
Loading

0 comments on commit 5201f36

Please sign in to comment.