Update [p]economyset slottime&paydaytime to use TimedeltaConverter and not accept negative integers #4807

Merged
felineturtlebird merged 14 commits from patch-9 into V3/develop 2021-02-15 22:25:04 +01:00
felineturtlebird commented 2021-02-12 01:47:02 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Paydaytime and Slottime command seconds param now only takes a positive integer, but accepts 0
Paydaytime and Slottime seconds param has a converter so 1d would be 86400 seconds, along with seconds, minutes, etc.

### Type - [x] Bugfix - [x] Enhancement - [ ] New feature ### Description of the changes Paydaytime and Slottime command seconds param now only takes a positive integer, but accepts 0 Paydaytime and Slottime seconds param has a converter so `1d` would be 86400 seconds, along with seconds, minutes, etc.
flaree commented 2021-02-12 01:48:33 +01:00 (Migrated from github.com)

There's already a timedelta converter you can make use of rather than making a new one

There's already a timedelta converter you can make use of rather than making a new one
felineturtlebird commented 2021-02-12 01:49:42 +01:00 (Migrated from github.com)

but that returns something like 0:00:50 right

but that returns something like 0:00:50 right
flaree commented 2021-02-12 01:50:58 +01:00 (Migrated from github.com)

Take a look at how slow mode if I remember takes use of it. You can convert a timedelta to seconds

Take a look at how slow mode if I remember takes use of it. You can convert a timedelta to seconds
felineturtlebird commented 2021-02-12 01:54:03 +01:00 (Migrated from github.com)

oh its a timedelta object? alr

oh its a timedelta object? alr
Jackenmen (Migrated from github.com) requested changes 2021-02-12 02:09:15 +01:00
Jackenmen (Migrated from github.com) left a comment

Thanks for making the fix, I have a few review comments that will need to be addressed before this can be approved and merged.

Thanks for making the fix, I have a few review comments that will need to be addressed before this can be approved and merged.
@ -11,6 +11,7 @@ import discord
from redbot.cogs.bank import is_owner_if_bank_global
Jackenmen (Migrated from github.com) commented 2021-02-12 01:58:24 +01:00

Now that you removed TimeConverter, these imports are no longer used and can be removed.

Now that you removed `TimeConverter`, these imports are no longer used and can be removed.
Jackenmen (Migrated from github.com) commented 2021-02-12 02:05:39 +01:00

You removed a line in here and added whitespace to the other line which makes this PR fail the style check. You need to ensure that there are two empty lines between the class definitions. Or you can run Black to reformat this for you as explained in our contributing guidelines

You removed a line in here and added whitespace to the other line which makes this PR fail the style check. You need to ensure that there are two empty lines between the class definitions. Or you can run Black to reformat this for you as explained in [our contributing guidelines](https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/CONTRIBUTING.md)
@ -910,2 +913,3 @@
Example:
Examples:
- `[p]economyset slottime 10`
- `[p]economyset slottime 10m`
Jackenmen (Migrated from github.com) commented 2021-02-12 02:06:45 +01:00

The example above and the description of the <seconds> parameter here should be updated to reflect the type of input that the used converter accepts.

The example above and the description of the `<seconds>` parameter here should be updated to reflect the type of input that the used converter accepts.
@ -926,1 +931,4 @@
async def paydaytime(
self, ctx: commands.Context, *, duration: TimedeltaConverter(default_unit="seconds")
):
"""Set the cooldown for the payday command.
Jackenmen (Migrated from github.com) commented 2021-02-12 02:08:16 +01:00

The example above and the description of the <seconds> parameter here should be updated to reflect the type of input that the used converter accepts.

The example above and the description of the `<seconds>` parameter here should be updated to reflect the type of input that the used converter accepts.
felineturtlebird (Migrated from github.com) reviewed 2021-02-12 02:10:26 +01:00
@ -926,1 +931,4 @@
async def paydaytime(
self, ctx: commands.Context, *, duration: TimedeltaConverter(default_unit="seconds")
):
"""Set the cooldown for the payday command.
felineturtlebird (Migrated from github.com) commented 2021-02-12 02:10:26 +01:00

finished

finished
Jackenmen (Migrated from github.com) requested changes 2021-02-14 03:16:35 +01:00
Jackenmen (Migrated from github.com) left a comment

There are few more things that need to be changed before merging.

After you deal with the review comments for the docstrings, you should also update the docs/cog_guides/economy.rst file with the updated contents of docstrings.

There are few more things that need to be changed before merging. After you deal with the review comments for the docstrings, you should also update the `docs/cog_guides/economy.rst` file with the updated contents of docstrings.
Jackenmen (Migrated from github.com) commented 2021-02-14 00:57:29 +01:00

You're still failing style here. There should be exactly 2 lines between class definitions and there can be no characters in the line, and currently, you have trailing spaces in here.

You're still failing style here. There should be exactly 2 lines between class definitions and there can be no characters in the line, and currently, you have trailing spaces in here.
@ -904,16 +905,21 @@ class Economy(commands.Cog):
)
Jackenmen (Migrated from github.com) commented 2021-02-14 03:09:27 +01:00

Now that this accepts numbers with units, it would make more sense if this argument were named duration (or time, cooldown, whatever you think makes sense here).

Remember to also update the docstring with the new name and update this code:

seconds = seconds.total_seconds()

to be this instead (or whatever name you choose for argument):

seconds = duration.total_seconds()
Now that this accepts numbers with units, it would make more sense if this argument were named `duration` (or `time`, `cooldown`, whatever you think makes sense here). Remember to also update the docstring with the new name and update this code: ```py seconds = seconds.total_seconds() ``` to be this instead (or whatever name you choose for argument): ```py seconds = duration.total_seconds() ```
Jackenmen (Migrated from github.com) commented 2021-02-14 03:11:38 +01:00

It probably makes sense to set default unit to seconds here:

    async def slottime(
        self, ctx: commands.Context, seconds: TimedeltaConverter(default_unit="seconds")
    ):
It probably makes sense to set default unit to seconds here: ```suggestion async def slottime( self, ctx: commands.Context, seconds: TimedeltaConverter(default_unit="seconds") ): ```
Jackenmen (Migrated from github.com) commented 2021-02-14 03:13:58 +01:00

This isn't really clear to the user, I would suggest sth like this:

        - `<seconds>` The new duration to wait in between uses of the slot machine. Default is 5 seconds.
        Accepts: seconds, minutes, hours, days, weeks
This isn't really clear to the user, I would suggest sth like this: ```suggestion - `<seconds>` The new duration to wait in between uses of the slot machine. Default is 5 seconds. Accepts: seconds, minutes, hours, days, weeks ```
Jackenmen (Migrated from github.com) commented 2021-02-14 03:09:59 +01:00

Now that this accepts numbers with units, it would make more sense if this argument were named duration (or time, cooldown, whatever you think makes sense here).

Remember to also update the docstring with the new name and update this code:

seconds = seconds.total_seconds()

to be this instead (or whatever name you choose for argument):

seconds = duration.total_seconds()
Now that this accepts numbers with units, it would make more sense if this argument were named `duration` (or `time`, `cooldown`, whatever you think makes sense here). Remember to also update the docstring with the new name and update this code: ```py seconds = seconds.total_seconds() ``` to be this instead (or whatever name you choose for argument): ```py seconds = duration.total_seconds() ```
Jackenmen (Migrated from github.com) commented 2021-02-14 03:12:03 +01:00

It probably makes sense to set default unit to seconds here:

    async def paydaytime(
        self, ctx: commands.Context, seconds: TimedeltaConverter(default_unit="seconds")
    ):
It probably makes sense to set default unit to seconds here: ```suggestion async def paydaytime( self, ctx: commands.Context, seconds: TimedeltaConverter(default_unit="seconds") ): ```
Jackenmen (Migrated from github.com) commented 2021-02-14 03:13:51 +01:00

This isn't really clear to the user, I would suggest sth like this:

        - `<seconds>` The new duration to wait in between uses of payday. Default is 5 minutes.
        Accepts: seconds, minutes, hours, days, weeks
This isn't really clear to the user, I would suggest sth like this: ```suggestion - `<seconds>` The new duration to wait in between uses of payday. Default is 5 minutes. Accepts: seconds, minutes, hours, days, weeks ```
Jackenmen commented 2021-02-14 03:31:48 +01:00 (Migrated from github.com)

I'm assuming you'll be working on it in full later (or are working on it now), can you send a comment in here once you finish, @Andeeeee? It would make it easier for me to know when this is ready to be reviewed again :)

I'm assuming you'll be working on it in full later (or are working on it now), can you send a comment in here once you finish, @Andeeeee? It would make it easier for me to know when this is ready to be reviewed again :)
felineturtlebird commented 2021-02-14 23:54:44 +01:00 (Migrated from github.com)

k done

k done
Jackenmen (Migrated from github.com) approved these changes 2021-02-15 00:44:27 +01:00
Jackenmen (Migrated from github.com) left a comment

Looks good to me, thanks for contributing.

Looks good to me, thanks for contributing.
Sign in to join this conversation.
No reviewers
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!4807
No description provided.