Skip to content

Commit

Permalink
Adding a condition will ignore user/global cooldown if it is null
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjpaz committed Jan 16, 2021
1 parent cfd6fc9 commit 82c21b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/twitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class TwitchShufflerListener {
isCoolingDown(user, command, message, flags, extra) {
let isCoolingDown = true;

if(extra.sinceLastCommand.any > 0 && extra.sinceLastCommand.any <= config.chatCooldownGlobal) {
if(config.chatCooldownGlobal && extra.sinceLastCommand.any > 0 && extra.sinceLastCommand.any <= config.chatCooldownGlobal) {
let cooldownLeft = Math.round((config.chatCooldownGlobal - extra.sinceLastCommand.any) / 1000);
logger.info(chalk.grey(`Ignoring swap due to the global cooldown ${cooldownLeft}`));
this.say(`@${user} command ${command} has ${cooldownLeft}s left the cooldown.`);
} else if(extra.sinceLastCommand.user > 0 && extra.sinceLastCommand.user <= config.chatCooldownUser) {
} else if(config.chatCooldownUser && extra.sinceLastCommand.user > 0 && extra.sinceLastCommand.user <= config.chatCooldownUser) {
let cooldownLeft = Math.round((config.chatCooldownUser - extra.sinceLastCommand.user) / 1000);
logger.info(chalk.grey(`Ignoring swap due to the user cooldown ${cooldownLeft}`));
this.say(`@${user} command ${command} has ${cooldownLeft}s left the cooldown.`);
Expand Down

0 comments on commit 82c21b4

Please sign in to comment.