Skip to content

Commit

Permalink
fix: Rejoin channels on new Token.
Browse files Browse the repository at this point in the history
  • Loading branch information
KararTY committed Aug 15, 2020
1 parent e263fbc commit 3b5a530
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Handlers/TokenHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ export default class TokenHandler extends DefaultHandler {
this.twitch.token = res

// Login / Relogin to Twitch
return await this.twitch.loginToTwitch()
return await this.twitch.loginToTwitch().then(async () => {
if (this.twitch.channels.size > 0) {
// Rejoin channels
const channelNames: string[] = []
for (const [, channel] of this.twitch.channels) {
channelNames.push(channel.name)
}

await this.twitch.ircClient.joinAll(channelNames).then(() => {
this.logger.info(`TokenHandler.onServerResponse() -> Twitch.JOINALL: Joined ${channelNames.join(', ')}.`)
}).catch((error) => {
this.logger.error({ err: error }, 'TokenHandler.onServerResponse() -> Twitch.JOINALL')
})
}
})
}
}

0 comments on commit 3b5a530

Please sign in to comment.