start-again / spookyBot

🎃 A spooky Discord bot
MIT License
9 stars 12 forks source link

Feature Extension HBS: Create a anti-spam protection for the command #35

Open illusi0nary opened 4 years ago

illusi0nary commented 4 years ago

Feature Extension of the Halloween Bot Scare (HBS) Currently you can spam the command as often as you want. In order to prevent spamming we want to have an anti-spam protection. The protection should prevent a single user from using the command too often in a configurable time span.

Details The bot remembers who requested a scare request and has a configurable time duration how long and how often a user can get the bot into the channel. If the user exceeds that limit the bot simpy ingores that user command.

illusi0nary commented 4 years ago

@tmetten mentioned that i did a little oopsie i wrote "song" instead of "scare" request. 😊

Thanks ! i corrected it!

tmttn commented 4 years ago

I have an idea for this:

  1. Add a timeout config value to each command you want protected.
  2. Modify message.js to perform a check based on the timeout and the user executing the command.
  3. Store the userid, command and date in a database when a command is executed. Make sure the database doesn't grow by updating existing entries based on userid and command.

This way, you can define different timeouts per command and the spam protected logic is contained to 1 location.

Later checks for roles could be added in message.js.