Add configurable per-user command cooldown - #75
Open
Saksham-official wants to merge 2 commits into
Open
Saksham-official wants to merge 2 commits into
Saksham-official wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a default per-user cooldown system to prevent command spamming, addressing #29.
What was done:
CooldownManagerinutils/cooldown.pyto track timestamps per user, calculate retry intervals, and prune old entries if the cache grows large.COMMAND_COOLDOWN_SECONDStoConfig(defaults to 3.0s, documented in.env.example). Setting it to 0 or negative disables the cooldown.@self.check) and slash commands (tree.interaction_check, scoped to application commands so autocomplete and buttons aren't affected).?fridgeinfun.pyortts.py) keep their existing rate limits and are skipped by the default gate.OWNER_ID) bypasses the cooldown.self.tree.on_error = self.on_app_command_errorso slash cooldown errors properly trigger the existing ephemeral response handler.tests/test_cooldown.py.Verified locally with
pytest,ruff check ., andmypy ..Closes #29