Skip to content

Commit

Permalink
fix(twitch): !game set should pick exact match if available (#4151)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Sep 25, 2020
1 parent 71db9ec commit 26d34e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bot/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class Twitch extends Core {
}
const games = await api.sendGameFromTwitch(null, opts.parameters);
if (Array.isArray(games) && games.length > 0) {
const status = await api.setTitleAndGame({ game: games[0] });
const exactMatchIdx = games.findIndex(name => name.toLowerCase() === opts.parameters.toLowerCase());
const status = await api.setTitleAndGame({ game: games[exactMatchIdx !== -1 ? exactMatchIdx : 0] });
return status ? [ { response: status.response, ...opts } ] : [];
}
return [{ response: translate('game.change.failed').replace(/\$title/g, api.stats.currentGame || 'n/a'), ...opts }];
Expand Down

0 comments on commit 26d34e5

Please sign in to comment.