Skip to content

Commit

Permalink
tweak logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BarryCarlyon committed May 10, 2024
1 parent 3795fda commit a24d9d1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/channel_points/channel_points.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ function eventsub() {
let { event } = payload;

let { id } = event;
message(`Process a channel.channel_points_custom_reward.update on ${id}`);

let { image, title, cost } = event;

let { is_enabled, is_paused } = event;
Expand Down Expand Up @@ -523,16 +525,17 @@ function eventsub() {


function requestHooks(session_id, user_id) {
message('Requesting Topics');
let topics = {
'channel.channel_points_custom_reward.add': { version: 1, condition: { broadcaster_user_id: user_id } },
'channel.channel_points_custom_reward.update': { version: 1, condition: { broadcaster_user_id: user_id } },
'channel.channel_points_custom_reward.remove': { version: 1, condition: { broadcaster_user_id: user_id } },
}

log(`Spawn Topics for ${user_id}`);
message(`Spawn Topics for ${user_id}`);

for (let type in topics) {
log(`Attempt create ${type} - ${user_id}`);
message(`Attempt create ${type} - ${user_id}`);
let { version, condition } = topics[type];

fetch(
Expand All @@ -558,14 +561,14 @@ function requestHooks(session_id, user_id) {
.then(resp => resp.json())
.then(resp => {
if (resp.error) {
log(`Error with eventsub Call ${type} Call: ${resp.message ? resp.message : ''}`);
message(`Error with eventsub Call ${type} Call: ${resp.message ? resp.message : ''}`);
} else {
log(`Created ${type}`);
message(`Eventsub Created ${type}`);
}
})
.catch(err => {
console.log(err);
log(`Error with eventsub Call ${type} Call: ${err.message ? err.message : ''}`);
message(`Error with eventsub Call ${type} Call: ${err.message ? err.message : ''}`);
});
}
}

0 comments on commit a24d9d1

Please sign in to comment.