diff options
author | 2022-06-21 15:09:57 +0200 | |
---|---|---|
committer | 2022-06-21 17:59:14 +0200 | |
commit | c8b23bbbd25372a55d6e3640b68cd96828922af0 (patch) | |
tree | 9d4512c2e36c753765888233f352af3ec26c201e /botcore | |
parent | Only append ids from Name nodes (diff) |
reword docstrings
Co-authored-by: MarkKoz <[email protected]>
Diffstat (limited to 'botcore')
-rw-r--r-- | botcore/utils/cooldown.py | 14 | ||||
-rw-r--r-- | botcore/utils/function.py | 9 |
2 files changed, 10 insertions, 13 deletions
diff --git a/botcore/utils/cooldown.py b/botcore/utils/cooldown.py index a06dce46..9e79e48a 100644 --- a/botcore/utils/cooldown.py +++ b/botcore/utils/cooldown.py @@ -70,9 +70,9 @@ class _CommandCooldownManager: """ Manage invocation cooldowns for a command through the arguments the command is called with. - A cooldown is set through `set_cooldown` for a channel with the given `call_arguments`, - if `is_on_cooldown` is checked within `cooldown_duration` seconds - of the call to `set_cooldown` with the same arguments, True is returned. + Use `set_cooldown` to set a cooldown, + and `is_on_cooldown` to check for a cooldown for a channel with the given arguments. + A cooldown lasts for `cooldown_duration` seconds. """ def __init__(self, *, cooldown_duration: float): @@ -99,7 +99,7 @@ class _CommandCooldownManager: cooldowns_list.append(_CooldownItem(call_arguments, timeout_timestamp)) def is_on_cooldown(self, channel: Hashable, call_arguments: _ArgsTuple) -> bool: - """Check whether ``call_arguments`` is on cooldown in ``channel``.""" + """Check whether `call_arguments` is on cooldown in `channel`.""" current_time = time.monotonic() try: return self._cooldowns.get((channel, call_arguments), -math.inf) > current_time @@ -115,9 +115,9 @@ class _CommandCooldownManager: async def _periodical_cleanup(self, initial_delay: float) -> None: """ - Wait for `initial_delay`, after that delete stale items every hour. + Delete stale items every hour after waiting for `initial_delay`. - The `initial_delay` ensures we're not running cleanups for every command at the same time. + The `initial_delay` ensures cleanups are not running for every command at the same time. """ await asyncio.sleep(initial_delay) while True: @@ -151,7 +151,7 @@ def block_duplicate_invocations( Args: cooldown_duration: Length of the cooldown in seconds. - send_notice: If True, the user is notified of the cooldown with a reply. + send_notice: If :obj:`True`, notify the user about the cooldown with a reply. Returns: A decorator that adds a wrapper which applies the cooldowns. diff --git a/botcore/utils/function.py b/botcore/utils/function.py index 1cde5cd9..e8d24e90 100644 --- a/botcore/utils/function.py +++ b/botcore/utils/function.py @@ -28,17 +28,14 @@ def update_wrapper_globals( ignored_conflict_names: Set[str] = frozenset(), ) -> Callable[_P, _R]: r""" - Update globals of the ``wrapper`` function with the globals from the ``wrapped`` function. + Create a copy of ``wrapper``\, the copy's globals are updated with ``wrapped``\'s globals. For forwardrefs in command annotations, discord.py uses the ``__global__`` attribute of the function - to resolve their values, with decorators that replace the function this breaks because they have + to resolve their values. This breaks for decorators that replace the function because they have their own globals. - This function creates a new function functionally identical to ``wrapper``\, which has the globals replaced with - a merge of ``wrapped``\s globals and the ``wrapper``\s globals. - .. warning:: - This function captures the state of ``wrapped``\'s module's globals when it's called, + This function captures the state of ``wrapped``\'s module's globals when it's called; changes won't be reflected in the new function's globals. Args: |