summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-03-03 19:30:22 +0000
committerGravatar Chris Lovering <[email protected]>2022-03-03 22:01:19 +0000
commitf9f58e5a574877c488cc3554bd498cd527efa017 (patch)
treec85bcdbc6230fbc9c19e6ef2f48fdf147ad484c8
parentMerge pull request #34 from python-discord/feat/site-api-wrapper (diff)
Surface apply_monkey_patches directly in the util namespace
-rw-r--r--botcore/utils/__init__.py21
-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)