Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit 4fcb2cbddd3fa731a8b43e0c7b4328b43553ab53
parent 55e23fec672708101779b03a7acf3f754793ab94
Author: Demonstrandum <moi@knutsen.co>
Date:   Wed, 18 Mar 2020 01:02:18 +0000

Fix spam only in the same channel.

Diffstat:
Mlib/main.ts | 26+++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/lib/main.ts b/lib/main.ts @@ -111,17 +111,21 @@ export class SimpOMatic { const current_command = this._COMMAND_HISTORY.last(); // Try and slow the fellas down a little. - const delta = current_command.createdTimestamp - last_command.createdTimestamp; - if (last_command.content === current_command.content - && delta <= 1400) { - if (delta <= 400) return; - return message.answer(`I can't help but notice you're running \ - the same commands over in rather rapid succession. - Would you like to slow down a little?`.squeeze()) - } - if (delta <= 900) { - if (delta <= 300) return; - return message.answer('Slow down there bucko.'); + if (last_command.channel === current_command.channel) { + // Only give spam warning if commands are coming + // fast _in the same channel_. + const delta = current_command.createdTimestamp - last_command.createdTimestamp; + if (last_command.content === current_command.content + && delta <= 1400) { + if (delta <= 400) return; + return message.answer(`I can't help but notice you're running \ + the same commands over in rather rapid succession. + Would you like to slow down a little?`.squeeze()) + } + if (delta <= 900) { + if (delta <= 300) return; + return message.answer('Slow down there bucko.'); + } } const content = message.content.trim().squeeze();