Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add reset_with_key and get_cooldown_time_with_key #1345

Merged
merged 8 commits into from
Apr 20, 2023
Merged

feat: add reset_with_key and get_cooldown_time_with_key #1345

merged 8 commits into from
Apr 20, 2023

Conversation

chronosirius
Copy link
Contributor

@chronosirius chronosirius commented Apr 13, 2023

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: For consistency, get_cooldown_with_key is async

Description

Cooldown resets with keys was a problem I had earlier; this solution is useful.
I made get_cooldown_with_key async for consistency as I said, so one doesn't have to remember which one is which.

await command.cooldown.reset_with_key(other_user)
await command.cooldown.get_cooldown_time_with_key(other_user)

vsc pylance did NOT complain.

Changes

  • made get_cooldown_with_key async
  • added reset_with_key
  • added get_cooldown_time_with_key

Related Issues

none

Test Scenarios

none

Python Compatibility

  • I've ensured my code works on Python 3.10.x (I don't have an installation of this.)
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files (couldn't install idk why but vsc pylance gave no problems) (Github pre-commit workflow)
  • I've tested my changes on supported Python versions (3.11)
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@chronosirius chronosirius marked this pull request as ready for review April 13, 2023 23:28
@LordOfPolls
Copy link
Contributor

These don't need to be async - all doing that does is limit what situations you can use these methods

@chronosirius
Copy link
Contributor Author

chronosirius commented Apr 14, 2023

Yes that's true, I will remove async. When I was going through the other files though I'm pretty sure I saw a "this doesn't really need to be async, but it is for consistency." or something to that extent. (Cooldown.reset_all, found it!) I will remove async, if you already haven't made it non-async I can fix that too.

@LordOfPolls
Copy link
Contributor

Yeah, that method was a contentious point for ux. Rule of thumb is if it doesn't need to be async, it shouldn't be - however yes reset_all is an outlier and as changing it would be a breaking change, it remains

@chronosirius
Copy link
Contributor Author

Alright then I will return it to the way it was (reset_all only).

@chronosirius
Copy link
Contributor Author

Could you check it on 3.10 for me?

@chronosirius
Copy link
Contributor Author

chronosirius commented Apr 14, 2023

How do I update documentation?
Edit: never mind, the documentation builder takes docstrings.

@chronosirius
Copy link
Contributor Author

haha, index.md still said bot.load! I fixed it to bot.load_extension.

@LordOfPolls
Copy link
Contributor

Your last change was out-of-scope. please revert it and create a new pr for that

@chronosirius
Copy link
Contributor Author

Alright.

@chronosirius chronosirius changed the title made get_cooldown_with_key async for consistency, added reset_with_ke… added reset_with_key and get_cooldown_time_with_key Apr 18, 2023
@AstreaTSS AstreaTSS changed the title added reset_with_key and get_cooldown_time_with_key feat: add reset_with_key and get_cooldown_time_with_key Apr 18, 2023
@LordOfPolls LordOfPolls merged commit a8f5a7f into interactions-py:unstable Apr 20, 2023
LordOfPolls added a commit that referenced this pull request Apr 22, 2023
* feat: support regex component callbacks (#1332)

* feat: support regex component callbacks

* docs: document regex matching component callback

* ci: correct from checks.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* chore: switch to MIT license (#1334)

* chore: switch to MIT license

* ci: correct from checks.

* docs: update license through github 

Uses githubs own license tools so the correct license is detected

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: add audit events (#1335)

* feat: add audit new mod events to audit log enum

* feat: add onboarding related events

see discord/discord-api-docs#6041

* refactor: change log level of missing value to warning (#1339)

Lets not scare people with "error"s ay?

* feat: add missing message types (#1338)

* feat: add missing message types

* feat: add deletable message types helper

* build: correct manifest

* feat: support avatar decorations (#1329)

* build: mirrored publish to d.py-interactions and interactions.py (#1336)

* style: add newline to end of manifest

* ci: fix migration issues in integration test bot

* fix: copy checks when inheriting (#1342)

Co-authored-by: Astrea49 <25420078+Astrea49@users.noreply.github.com>

* feat: cooldown upgrades (#1323)

* docs: add changelog page

* style: add EOF newline

* docs: add 5.1.0 to changelog.md

* style: remove trailing whitespace

* fix: reintroduce imports at namespace linter removed

* feat: sync improvements (#1328)

* refactor: improve readability of sync logic

* fix: improve initial sync caching

* docs: add docstring to update_command_cache

* feat: add command deletion to debug ext

* feat: rate limit improvements  (#1321)

* fix: refactor all http routes to generate buckets properly

* fix: resolve routes regex missed

* feat: allow concurrent api calls from the same bucket

* feat: restore bucketLock.locked property

* feat: further bucketlock improvements

* feat: allow bucketlock blocking to be toggled

* refactor: resolve ruff compliant

* fix: correct webhook http

* fix: wrong check condition in the component callback (#1352)

* fix: error when dispatch component callback (#1351)

* docs: adjust and fix many parts of the docs (#1353)

* docs: adjust and fix many parts of the docs

* docs: add note about event object for v4 migration

* docs: replace more instances of InteractionContext

---------

Co-authored-by: Astrea49 <25420078+Astrea49@users.noreply.github.com>

* feat: caching improvements (#1350)

* feat: add support for force fetching

* feat: track if a user object has been fetched

* feat: add force flag to client helper methods

* feat: update all cache fetch methods to have  a force param

* feat: add reset_with_key and get_cooldown_time_with_key (#1345)

* made get_cooldown_with_key async for consistency, added reset_with_key and get_cooldown_time_with_key

* ci: correct from checks.

* fixed pre-commit problems

* comment on #1345, resolved

* made Cooldown.reset_all async #1345

* bot.load => bot.load_extension

* reverted 8217f4e

* made get_cooldown_time_with_key and reset_with_key sync

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Astrea <25420078+AstreaTSS@users.noreply.github.com>
Co-authored-by: Astrea49 <25420078+Astrea49@users.noreply.github.com>
Co-authored-by: Damego <damego.dev@gmail.com>
Co-authored-by: chronosirius <73508925+chronosirius@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants