Open StrawbrryFlurry opened 3 years ago
Does the Watson library contain any user/guild classes for retrieving user metadata? I think we could check on every request whether or not a specific user has exceeded a rate limit during a specific timespan.
Yeah, I think we could implement this pretty easily. The data doesn't really need to be persistent so we just store it in memory. A map should work just fine for this but redis might also be worth a try.
A very basic implementation would look something like this:
In the RouteHandlerFactory
, we add a map for caching command calls for each user as well as their guild.
In the createCommandHandler
, which basically creates the function that is called once we match a certain command from a user message, we add an additional step that handles the rate-limiting.
I've created a new branch with an example implementation of how this could look like on a per guild/user basis: Commit
Feature rate-limiting for commands on a user/guild-based context.