@@ -387,6 +387,22 @@ async def get_cooldown_time(self, context: "BaseContext") -> float:
387387 cooldown = await self .get_cooldown (context )
388388 return cooldown .get_cooldown_time ()
389389
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+
390406 async def on_cooldown (self , context : "BaseContext" ) -> bool :
391407 """
392408 Returns the cooldown state of the command.
@@ -423,6 +439,25 @@ async def reset(self, context: "BaseContext") -> None:
423439 cooldown = await self .get_cooldown (context )
424440 cooldown .reset ()
425441
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+
426461
427462class MaxConcurrency :
428463 """
0 commit comments