From 090659164c250c8336e71154bd454832d653a3ee Mon Sep 17 00:00:00 2001 From: Lluis Date: Thu, 17 Oct 2024 00:37:13 +0200 Subject: [PATCH] redemption reward event sub --- lib/eventSub.js | 5 +++++ lib/messenger.js | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/eventSub.js b/lib/eventSub.js index 983681e..f94e62c 100644 --- a/lib/eventSub.js +++ b/lib/eventSub.js @@ -32,6 +32,11 @@ class EventSub { console.log(`${event.userDisplayName} just followed ${event.broadcasterDisplayName}!`); this.bot.say(`#${config.twitch.channels}`, `Gracias por seguirnos ${event.userDisplayName}!`) }); + + this.middleware.onChannelRedemptionAddForReward(channelId, "427b3e63-e6cd-4d36-8954-9c7198af0a1d", event => { + console.log(`${event.userDisplayName} ha canjeado ${event.rewardTitle}!`); + this.bot.say(`#${config.twitch.channels}`, `${event.userDisplayName} ha canjeado ${event.rewardTitle}!`) + }); } } diff --git a/lib/messenger.js b/lib/messenger.js index 5c58ba0..f293a8a 100644 --- a/lib/messenger.js +++ b/lib/messenger.js @@ -16,6 +16,7 @@ class Messenger { async init() { await this.tokenAutoRefresh() + await this.channelTokenAutoRefresh() const opts = { options: { debug: true }, @@ -69,10 +70,6 @@ class Messenger { authProvider.addUser(parseInt(config.twitch.roomId), tokenData, ['chat']) } - getBot () { - return this.bot - } - listen () { const apiClient = new ApiClient({ authProvider: this.authProvider })