Skip to content

Commit

Permalink
fix(twitch): slowdown eventsub init
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Mar 16, 2023
1 parent 82b1cad commit bd3b5e5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/services/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,23 @@ class Twitch extends Service {
await updateBroadcasterType();
info(`TWITCH: Broadcaster token initialized OK for ${this.broadcasterUsername}#${this.broadcasterId} (type: ${this.broadcasterType}) with scopes: ${this.broadcasterCurrentScopes.join(', ')}`);
}
}

@onChange(['botTokenValid', 'broadcasterTokenValid'])
onTokenValidChange() {
this.eventsub?.listener.stop();
if (this.broadcasterTokenValid && this.botTokenValid) {
this.tmi = new Chat(this.authProvider);
this.eventsub = new EventSub(this.apiClient);
setTimeout(() => {
if (!this.authProvider || !this.apiClient) {
return;
}
this.tmi = new Chat(this.authProvider);
this.eventsub = new EventSub(this.apiClient);

if (this.broadcasterId === this.botId) {
error(`You have set bot and broadcaster oauth for same user ${this.broadcasterUsername}#${this.broadcasterId}. This is *NOT RECOMMENDED*. Please use *SEPARATE* account for bot.`);
}
if (this.broadcasterId === this.botId) {
error(`You have set bot and broadcaster oauth for same user ${this.broadcasterUsername}#${this.broadcasterId}. This is *NOT RECOMMENDED*. Please use *SEPARATE* account for bot.`);
}
}, 10000);
} else {
this.tmi = null;
this.eventsub = null;
Expand Down

0 comments on commit bd3b5e5

Please sign in to comment.