[p]slowmode #2734
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!2734
Loading…
Reference in a new issue
No description provided.
Delete branch "patch-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Description of the changes
This PR adds a
[p]slowmode [interval=0]command, for easy slowmode management on a channel. This lets anyone withManage Channelspermission or aModrole to change the slowmode setting.Could be changed to require
0to disable instead of having it there by default, this is up for discussion.@ -0,0 +1,41 @@import recan you add human time format converter?
seconds, minutes, hours etc
@ -0,0 +1,41 @@import reAs the input parameter? Or for the
Slowmode interval is now {interval} seconds.feedback message?@ -0,0 +1,41 @@import reboth
I don't believe it's for us to decide, if mods should be able to use this and I think this should be changed so only people with admin role or manage channels permission can use it and just leave it to Red users to decide if they want to allow it to mods role (which they can do by using permissions cog)
This last commit comes with a simple time converter per request, that will convert input like
5,5s,5mor5hto appropriate time interval.humanized_timedeltafromutilsis now used to pretty-print the slowmode interval set. Addressing jack's concerns, I've also bumped the decorator toadmin_or_permissions, with the intention that it could be overwritten with permissions later if needed as suggested.A proper, fully fledged time interval converter could be used here, but I believe this is beyond this simple PR. Such converter could be really useful to everyone using Red in general, not only here in the Mod cog, and could be incorporated here at a later date when available.
@ -0,0 +1,41 @@import reShould be resolved with the recent commit.
Assuming this works properly (It looks solid, but I won't have a chance to test until later) I'm fine with merging prior to having a generalized timedelta converter in core and adding it and switching this to it later.
For anyone who goes to add that, the converter should likely be generalized in such a way in which valid units can be passed as well as an upper and lower bound on the time so that all of that is handled in the conversion step.
This works great for an initial addition. I do have a small change request here:
If this is going to use a simplistic handling prior to there being a generalized converter, this should throw an error to not cause confusion, rather than allow it to succeed with an ambiguous meaning.
a tweak to the regex used, or using
re.fullmatchshould be reasonably sufficient for this on the short term until the generalized converter is done.Right, I was using
matchinstead ofsearchalready, but forgot that it still requires an explicit line end. Should be as easy as adding$at the end of the regex pattern.@ -0,0 +1,41 @@import rePlease use
_("message").format()rather than f-strings for user-facing strings. f-strings fundamentally can't work with gettext due to order of evaluation.@ -0,0 +1,41 @@import reRight, switched it to the format method, slightly shorter than your version - hopefully that's alright.
@ -0,0 +1,41 @@import reThis should be resolved once #2736 will be accepted, so I can use it here.
This should be ready to go now.
Thanks for your contribution! Works well :)