Skip to content

Commit

Permalink
fix(emotes): remove usage of setImmediate when caster is not set
Browse files Browse the repository at this point in the history
setImmediate is using too much of cpu cycles
  • Loading branch information
sogehige committed Aug 30, 2022
1 parent 267b62b commit d47bab3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/emotes.ts
@@ -1,5 +1,3 @@
import { setImmediate } from 'timers';

import { shuffle } from '@sogebot/ui-helpers/array';
import * as constants from '@sogebot/ui-helpers/constants';
import axios from 'axios';
Expand Down Expand Up @@ -197,6 +195,10 @@ class Emotes extends Core {
}

async fetchEmotesGlobal () {
const botUsername = variables.get('services.twitch.botUsername') as string;
if (botUsername.length === 0) {
return;
}
this.fetch.global = true;

// we want to update once every week
Expand All @@ -205,6 +207,7 @@ class Emotes extends Core {
if (this.lastGlobalEmoteChk !== 0) {
info('EMOTES: Fetching global emotes');
}

const clientBot = await client('bot');
const emotes = await clientBot.chat.getGlobalEmotes();
this.lastGlobalEmoteChk = Date.now();
Expand Down Expand Up @@ -340,7 +343,6 @@ class Emotes extends Core {
const broadcasterUsername = variables.get('services.twitch.broadcasterUsername') as string;

if (broadcasterUsername.length === 0) {
setImmediate(() => this.fetchEmotesBTTV());
return;
}

Expand Down

0 comments on commit d47bab3

Please sign in to comment.