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 })