Open mahony0 opened 5 years ago
Do you see this line https://github.com/MyTheValentinus/twitch-bot/blob/6063287cae29ab3e1f00bc1c220ebe10487b6722/modules/commands/Commands.php#L121 ? I think is what you mention ?
Yes, this line gives $command->getCommand() as key: https://github.com/MyTheValentinus/twitch-bot/blob/6063287cae29ab3e1f00bc1c220ebe10487b6722/modules/commands/Commands.php#L121
but this line checks $this->getRealCommand($command->getCommand()) as key: https://github.com/MyTheValentinus/twitch-bot/blob/6063287cae29ab3e1f00bc1c220ebe10487b6722/modules/commands/Commands.php#L95
so, as getCommand() and getRealCommand($command->getCommand()) not returning same results, delaying is not working as intended. We tested and there's no delay on sending commands for viewers. All viewers can send command without delay with current code.
Hmmm stange, this module work on my channel, the only possible bug is line 121 i think, need to get real command not only get command, in case of alias command, the user can spam an alias. I need to debug, is old code ^^
Sure, I made it work by applying these changes:
/*
* line: 93
*/
$cmd = $command->getCommand();
if (isset($this->lastCommands[$cmd])) {
$lastUsedTime = $this->lastCommands[$cmd];
} else {
$lastUsedTime = time() - $this->delay;
}
// .....
/*
* line: 121
*/
$this->lastCommands[$cmd] = time();
https://github.com/MyTheValentinus/twitch-bot/blob/6063287cae29ab3e1f00bc1c220ebe10487b6722/modules/commands/Commands.php#L95
on this line, $this->lastCommands[$cmd] is not returning any result because it needs to be indexed with $command->getCommand() keys, not $cmd.
If you can approve this is a bug, I can send PR.