[V3 Mod] Timed mute #2103

Closed
opened 2018-09-06 22:40:01 +02:00 by laggron42 · 5 comments
laggron42 commented 2018-09-06 22:40:01 +02:00 (Migrated from github.com)

Feature request

Select the type of feature you are requesting:

  • Cog
  • Command
  • API functionality

Describe your requested feature

An included timed mute for the mod cog is requested a lot currently, and would be a nice feature. I'm thinking about something like Dyno for the arguments, and would give something like this:

[p]mute guild @someone 30m my random reason

30m = 30 minutes
2h = 2 hours
4d = 4 days
...

Please give your feedback about this to know what would be the best, I'm planning to code this for the next beta (if there is one before RC)

# Feature request <!-- This template is for feature requests. Please fill out the following: --> #### Select the type of feature you are requesting: <!-- To check a box, replace the space between the [] with a x --> - [ ] Cog - [x] Command - [ ] API functionality #### Describe your requested feature <!-- Feel free to describe in as much detail as you wish. If you are requesting a cog to be included in core: - Describe the functionality in as much detail as possible - Include the command structure, if possible - Please note that unless it's something that should be core functionality, we reserve the right to reject your suggestion and point you to our cog board to request it for a third-party cog If you are requesting a command: - Include what cog it should be in and a name for the command - Describe the intended functionality for the command - Note any restrictions on who can use the command or where it can be used If you are requesting API functionality: - Describe what it should do - Note whether it is to extend existing functionality or introduce new functionality --> An included timed mute for the mod cog is requested a lot currently, and would be a nice feature. I'm thinking about something like Dyno for the arguments, and would give something like this: ``` [p]mute guild @someone 30m my random reason ``` `30m` = 30 minutes `2h` = 2 hours `4d` = 4 days ... Please give your feedback about this to know what would be the best, I'm planning to code this for the next beta (if there is one before RC)
mikeshardmind commented 2018-09-07 00:20:51 +02:00 (Migrated from github.com)

If you'd like to do this, that would actually be wonderful. There was some discussion in discord about this earlier today actually, and the details for what was needed for this could be summed up as:

  • All logic abstracted out of commands; Commands should just call the correct functions and schedule a corresponding the corresponding unmute.
  • Unmute should be handled properly even in the case of bot uptime interruptions,
  • Time handling should feel natural. (This can include added dependencies within reason, such as humanize)
  • Logic should be easily modifiable to allow using a mute role at a later date. This should be accomplished naturally by breaking the logic out of the commands anyway.

If this is beyond what you would want to do, it will likely still be ready before RC1 as there are others interested in making this happen.

If you'd like to do this, that would actually be wonderful. There was some discussion in discord about this earlier today actually, and the details for what was needed for this could be summed up as: - All logic abstracted out of commands; Commands should just call the correct functions and schedule a corresponding the corresponding unmute. - Unmute should be handled properly even in the case of bot uptime interruptions, - Time handling should feel natural. (This can include added dependencies within reason, such as `humanize`) - Logic should be easily modifiable to allow using a mute role at a later date. This should be accomplished naturally by breaking the logic out of the commands anyway. If this is beyond what you would want to do, it will likely still be ready before RC1 as there are others interested in making this happen.
PgoTracker commented 2018-09-08 12:49:35 +02:00 (Migrated from github.com)

Why not go a step further and allow any command to be ran on a delay. Although maybe that wouldn't warrant being core

Why not go a step further and allow any command to be ran on a delay. Although maybe that wouldn't warrant being core
laggron42 commented 2018-09-08 16:21:54 +02:00 (Migrated from github.com)

I'm having some difficulties with the libraries. I cannot find a good one for what I need:

  • datetime.datetime have the good arguments and operations, but represents a date (year cannot be 0)
  • datetime.time cannot be more than a day
  • datetime.timedelta cannot represent years, months, hours, minuts

If you know any good libraries where you can set separately every unit, I'd like to know.

I'm having some difficulties with the libraries. I cannot find a good one for what I need: - `datetime.datetime` have the good arguments and operations, but represents a date (year cannot be 0) - `datetime.time` cannot be more than a day - `datetime.timedelta` cannot represent years, months, hours, minuts If you know any good libraries where you can set separately every unit, I'd like to know.
mikeshardmind commented 2018-09-08 16:55:29 +02:00 (Migrated from github.com)

Not sure an extra lib is needed, it was just an option. Here's a recipe from some old code that should work fine.

import re
from datetime import timedelta

TIME_RE = re.compile(r"((?P<days>\d+?)\s?(d(ays?)?))?\s?((?P<hours>\d+?)\s?(hours?|hrs|hr?))?\s?((?P<minutes>\d+?)\s?(minutes?|mins?|m))?\s?((?P<seconds>\d+?)\s?(seconds?|secs?|s))?\s?", re.I)

def parse_timedelta(some_input: str) -> timedelta:
    matches = TIME_RE.match(some_input)
    params = {k: int(v) for k, v in matches.groupdict().items() if None not in (k, v)}
    return timedelta(**params)

This could be made more robust with something such as pyparsing, but is likely overkill here.

Not sure an extra lib is needed, it was just an option. Here's a recipe from some old code that should work fine. ```py import re from datetime import timedelta TIME_RE = re.compile(r"((?P<days>\d+?)\s?(d(ays?)?))?\s?((?P<hours>\d+?)\s?(hours?|hrs|hr?))?\s?((?P<minutes>\d+?)\s?(minutes?|mins?|m))?\s?((?P<seconds>\d+?)\s?(seconds?|secs?|s))?\s?", re.I) def parse_timedelta(some_input: str) -> timedelta: matches = TIME_RE.match(some_input) params = {k: int(v) for k, v in matches.groupdict().items() if None not in (k, v)} return timedelta(**params) ``` This could be made more robust with something such as pyparsing, but is likely overkill here.
mikeshardmind commented 2020-01-04 08:29:34 +01:00 (Migrated from github.com)

replaced by #3270

replaced by #3270
Sign in to join this conversation.
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 milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#2103
No description provided.