diff options
| -rw-r--r-- | botcore/utils/__init__.py | 21 | ||||
| -rw-r--r-- | botcore/utils/_monkey_patches.py (renamed from botcore/utils/monkey_patches.py) | 15 | 
2 files changed, 21 insertions, 15 deletions
| diff --git a/botcore/utils/__init__.py b/botcore/utils/__init__.py index 890f30da..07ded04d 100644 --- a/botcore/utils/__init__.py +++ b/botcore/utils/__init__.py @@ -1,14 +1,31 @@  """Useful utilities and tools for Discord bot development.""" -from botcore.utils import (caching, channel, extensions, logging, members, monkey_patches, regex, scheduling) +from botcore.utils import _monkey_patches, caching, channel, extensions, logging, members, regex, scheduling + + +def apply_monkey_patches() -> None: +    """ +    Applies all common monkey patches for our bots. + +    Patches :obj:`disnake.ext.commands.Command` and :obj:`disnake.ext.commands.Group` to support root aliases. +        A ``root_aliases`` keyword argument is added to these two objects, which is a sequence of alias names +        that will act as top-level groups rather than being aliases of the command's group. + +        It's stored as an attribute also named ``root_aliases`` + +    Patches disnake's internal ``send_typing`` method so that it ignores 403 errors from Discord. +        When under heavy load Discord has added a CloudFlare worker to this route, which causes 403 errors to be thrown. +    """ +    _monkey_patches._apply_monkey_patches() +  __all__ = [ +    apply_monkey_patches,      caching,      channel,      extensions,      logging,      members, -    monkey_patches,      regex,      scheduling,  ] diff --git a/botcore/utils/monkey_patches.py b/botcore/utils/_monkey_patches.py index abbb37a5..89238756 100644 --- a/botcore/utils/monkey_patches.py +++ b/botcore/utils/_monkey_patches.py @@ -62,19 +62,8 @@ def _patch_typing() -> None:      http.HTTPClient.send_typing = honeybadger_type -def apply_monkey_patches() -> None: -    """ -    Applies all common monkey patches for our bots. - -    Patches :obj:`disnake.ext.commands.Command` and :obj:`disnake.ext.commands.Group` to support root aliases. -        A ``root_aliases`` keyword argument is added to these two objects, which is a sequence of alias names -        that will act as top-level groups rather than being aliases of the command's group. - -        It's stored as an attribute also named ``root_aliases`` - -    Patches disnake's internal ``send_typing`` method so that it ignores 403 errors from Discord. -        When under heavy load Discord has added a CloudFlare worker to this route, which causes 403 errors to be thrown. -    """ +def _apply_monkey_patches() -> None: +    """This is surfaced directly in botcore.utils.apply_monkey_patches()."""      commands.command = partial(commands.command, cls=_Command)      commands.GroupMixin.command = partialmethod(commands.GroupMixin.command, cls=_Command) | 
