aboutsummaryrefslogtreecommitdiff
path: root/discord/ext/commands/cooldowns.py
Commit message (Collapse)AuthorAgeFilesLines
* [commands] Document / type-hint cooldownJosh2021-08-101-57/+132
|
* [commands] Remove window reassignment when tokens reach 0Rapptz2021-07-041-5/+0
|
* [commands] Add back CommandOnCooldown.typeRapptz2021-07-021-0/+4
|
* [commands] Fix errors with cooldown mappingsRapptz2021-04-111-2/+7
|
* [commands] Provide a dynamic cooldown system Dan Hess2021-04-101-12/+30
|
* Use f-strings in more places that were missed.Rapptz2021-04-081-3/+3
|
* Modernize code to use f-stringsRapptz2021-04-041-3/+1
| | | | | This also removes the encoding on the top, since Python 3 does it by default. It also changes some methods to use `yield from`.
* [commands] allow arbitrary callables in cooldownMikey2021-03-281-3/+6
|
* Change copyright year to presentNihaal Sangha2021-01-151-1/+1
|
* [commands] Provide a way to retrieve time left for a cooldown Dan Hess2020-08-051-0/+9
|
* [commands] Fix a typo in the docstring of the internal _Semaphore classs0lst1ce2020-04-041-1/+1
|
* [commands] Only clean semaphore when there are no waitersRapptz2020-01-211-1/+4
|
* [commands] Refactor BucketType to not repeat in other places in codeRapptz2020-01-211-39/+24
|
* [commands] Add max_concurrency decoratorRapptz2020-01-211-0/+130
|
* Bump copyright year to 2020Rapptz2020-01-191-1/+1
| | | | Closes #2510
* [commands] Add role cooldown bucketBluePhoenixGame2019-08-111-0/+9
|
* Replace Enum with an internal one for significant speed improvements.Rapptz2019-06-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has been a massive pain point for me personally due to the poor design of the Enum class leading to the common use cases used in the library being significantly slow. Since this Enum is not public facing in terms of *creation*, I can only implement the APIs that are used when *accessing* them. This Enum is a drop-in replacement to the pre-existing enum.Enum class except it comes with significant speed-ups. Since this is a lot to go over, I will let the numbers speak for themselves: In [4]: %timeit enums.try_enum(enums.Status, 'offline') 263 ns ± 34.3 ns per loop (7 runs, 1000000 loops each) In [5]: %timeit NeoStatus.try_value('offline') 134 ns ± 0.859 ns per loop (7 runs, 10000000 loops each) In [6]: %timeit enums.Status.offline 116 ns ± 0.378 ns per loop (7 runs, 10000000 loops each) In [7]: %timeit NeoStatus.offline 31.6 ns ± 0.327 ns per loop (7 runs, 10000000 loops each) In [8]: %timeit enums.Status.offline.value 382 ns ± 15.2 ns per loop (7 runs, 1000000 loops each) In [9]: %timeit NeoStatus.offline.value 65.5 ns ± 0.953 ns per loop (7 runs, 10000000 loops each) In [10]: %timeit str(enums.Status.offline) 630 ns ± 14.8 ns per loop (7 runs, 1000000 loops each) In [11]: %timeit str(NeoStatus.offline) 253 ns ± 3.53 ns per loop (7 runs, 1000000 loops each) In [12]: %timeit enums.Status('offline') 697 ns ± 8.42 ns per loop (7 runs, 1000000 loops each) In [13]: %timeit NeoStatus('offline') 182 ns ± 1.83 ns per loop (7 runs, 10000000 loops each)
* [commands] Allow passing `current` to more cooldown mapping methods.Rapptz2019-04-241-4/+8
| | | | Also adds a CooldownMapping.update_rate_limit helper function.
* Consistent use of __all__ to prevent merge conflicts.Rapptz2019-04-201-1/+5
|
* [commands] Allow passing reference time to update_rate_limitRapptz2019-04-141-2/+2
|
* [commands] Fix issue with decorator order with checks and cooldownsRapptz2019-02-231-0/+5
| | | | Now they're just explicitly copied.
* Bumped copyright years to 2019.Dante Dam2019-01-281-1/+1
|
* Add channel category cooldown bucket typeDice2018-11-241-5/+8
|
* [lint] Fix incorrect and inconsistent whitespaceHornwitser2018-08-221-0/+1
| | | | Adjust whitespace to be consistent with the rest of the library.
* [commands] Added BucketType.members for cooldownsClement2018-08-221-1/+4
|
* [commands] Minor speed-up for the BucketType.guild case.Rapptz2017-10-081-1/+1
| | | | | | | | None case: 344ns ± 24.4ns -> 49.9ns ± 1.39ns Valid case: 128ns ± 2.76ns -> 42.7ns ± 0.459ns
* [commands] Make CooldownMapping.get_bucket take Message instead.Rapptz2017-10-081-4/+3
| | | | | Requiring a full blown Context might be a bit overkill considering we only use a single attribute from it.
* [commands] Split Cooldown state processing to two different functions.MysterialPy2017-10-031-7/+14
| | | | | This allows us to check if we are rate limited without creating a new cool-down window for the command.
* [commands] Add CooldownMapping.from_cooldown factory classmethod.Rapptz2017-08-271-0/+4
|
* Update copyright year to 2017.Rapptz2017-01-201-1/+1
|
* Rename Server to Guild everywhere.Rapptz2017-01-031-3/+3
|
* Slots use tuples instead now.Rapptz2017-01-031-1/+1
|
* [commands] Added a method to reset command cooldown.Dan Hess2016-09-081-0/+5
|
* [commands] Implement a command cooldown system.Rapptz2016-07-221-0/+121
The way the command cooldown works is using a windowed way of doing it. That is, if we have a cooldown of 2 commands every 30 seconds then if we do a single command, we have 30 seconds to do the second command or else we will get rate limited. This more or less matches the common expectations on how cooldowns should be. These cooldowns can be bucketed up to a single dimension of depth for a per-user, per-guild, or per-channel basis. Of course, a global bucket is also provided. These cannot be mixed, e.g. no per-channel per-user cooldowns. When a command cooldown is triggered, the error handlers will receive a an exception of type CommandOnCooldown with proper information regarding the cooldown such as retry_after and the bucket information itself.