Add a timedelta converter #2736
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!2736
Loading…
Reference in a new issue
No description provided.
Delete branch "timedelta-converter"
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 reuses a lot of logic from @mikeshardmind 's scheduler cog with permission
It adds a timedelta converter
It keeps it generalized as requested
It keeps the function available for non converter use as requested
There are a couple of things which need fixing, beyond that I think the arguments other than the user input here are better suited as keyword only in all instances for the timedelta conversion stuff.
@ -1,5 +1,6 @@import reyou've put these in the wrong order for the signature of the class
Hmm, what about adding something along the lines of a
default_unit, that would be used when the argument parsed would be an integer only?This would be really helpful for other cogs where passing just a number would default to the unit specified, while passing numbers with units would be converted as it currently is now.
The argument could easily be checked with
argument.isdigit()to determine if it should be parsed withdefault_unitor not.Finally, setting
default_unittoNone(probably by default) would disable this additional functionality altogether.Is there any benefit to this beyond not using a union converter? I don't think guessing or assuming units in a converter designed to accept multiple is a good idea.
I somewhat agree, except in the case of being guaranteed a specific type rather either using an int converter or needing to write a custom converter on top of this for that case.
I'm not completely made up on this either way, and think that while it's worth discussion, it's not worth delaying the addition since it can be added non-breakingly later, and in the mean time there are other options for this specific case.
This is ready to go, there may be more to add to this later, but it's in a good place to get people using it for now.