@@ -387,6 +387,22 @@ async def get_cooldown_time(self, context: "BaseContext") -> float:
387
387
cooldown = await self .get_cooldown (context )
388
388
return cooldown .get_cooldown_time ()
389
389
390
+ def get_cooldown_time_with_key (self , key : Any , * , create : bool = False ) -> float :
391
+ """
392
+ Get the remaining cooldown time with a key instead of the context.
393
+
394
+ Note:
395
+ The preferred way to get the cooldown system is to use `get_cooldown` as it will use the context to get the correct key.
396
+
397
+ Args:
398
+ key: The key to get the cooldown system for
399
+ create: Whether to create a new cooldown system if one does not exist
400
+ """
401
+ cooldown = self .get_cooldown_with_key (key , create = create )
402
+ if cooldown is not None :
403
+ return cooldown .get_cooldown_time ()
404
+ return 0
405
+
390
406
async def on_cooldown (self , context : "BaseContext" ) -> bool :
391
407
"""
392
408
Returns the cooldown state of the command.
@@ -423,6 +439,25 @@ async def reset(self, context: "BaseContext") -> None:
423
439
cooldown = await self .get_cooldown (context )
424
440
cooldown .reset ()
425
441
442
+ def reset_with_key (self , key : Any ) -> bool :
443
+ """
444
+ Resets the cooldown for the bucket associated with the provided key.
445
+
446
+ Note:
447
+ The preferred way to reset the cooldown system is to use `reset_cooldown` as it will use the context to reset the correct cooldown.
448
+
449
+ Args:
450
+ key: The key to reset the cooldown system for
451
+
452
+ Returns:
453
+ True if the key existed and was reset successfully, False if the key didn't exist.
454
+ """
455
+ cooldown = self .get_cooldown_with_key (key )
456
+ if cooldown is not None :
457
+ cooldown .reset ()
458
+ return True
459
+ return False
460
+
426
461
427
462
class MaxConcurrency :
428
463
"""
0 commit comments