diff options
-rw-r--r-- | botcore/utils/__init__.py | 4 | ||||
-rw-r--r-- | botcore/utils/_monkey_patches.py | 12 | ||||
-rw-r--r-- | botcore/utils/channel.py | 20 | ||||
-rw-r--r-- | botcore/utils/extensions.py | 2 | ||||
-rw-r--r-- | botcore/utils/members.py | 24 | ||||
-rw-r--r-- | docs/conf.py | 2 |
6 files changed, 32 insertions, 32 deletions
diff --git a/botcore/utils/__init__.py b/botcore/utils/__init__.py index 07ded04d..fe906075 100644 --- a/botcore/utils/__init__.py +++ b/botcore/utils/__init__.py @@ -7,13 +7,13 @@ 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. + Patches :obj:`discord.ext.commands.Command` and :obj:`discord.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. + Patches discord'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() diff --git a/botcore/utils/_monkey_patches.py b/botcore/utils/_monkey_patches.py index 89238756..f2c6c100 100644 --- a/botcore/utils/_monkey_patches.py +++ b/botcore/utils/_monkey_patches.py @@ -1,18 +1,18 @@ -"""Contains all common monkey patches, used to alter disnake to fit our needs.""" +"""Contains all common monkey patches, used to alter discord to fit our needs.""" import logging from datetime import datetime, timedelta from functools import partial, partialmethod -from disnake import Forbidden, http -from disnake.ext import commands +from discord import Forbidden, http +from discord.ext import commands log = logging.getLogger(__name__) class _Command(commands.Command): """ - A :obj:`disnake.ext.commands.Command` subclass which supports root aliases. + A :obj:`discord.ext.commands.Command` subclass which supports root aliases. A ``root_aliases`` keyword argument is added, which is a sequence of alias names that will act as top-level commands rather than being aliases of the command's group. It's stored as an attribute @@ -29,7 +29,7 @@ class _Command(commands.Command): class _Group(commands.Group, _Command): """ - A :obj:`disnake.ext.commands.Group` subclass which supports root aliases. + A :obj:`discord.ext.commands.Group` subclass which supports root aliases. A ``root_aliases`` keyword argument is added, 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 @@ -41,7 +41,7 @@ def _patch_typing() -> None: """ Sometimes Discord turns off typing events by throwing 403s. - Handle those issues by patching disnake's internal ``send_typing`` method so it ignores 403s in general. + Handle those issues by patching discord's internal ``send_typing`` method so it ignores 403s in general. """ log.debug("Patching send_typing, which should fix things breaking when Discord disables typing events. Stay safe!") diff --git a/botcore/utils/channel.py b/botcore/utils/channel.py index d586098f..c09d53bf 100644 --- a/botcore/utils/channel.py +++ b/botcore/utils/channel.py @@ -1,14 +1,14 @@ -"""Useful helper functions for interacting with various disnake channel objects.""" +"""Useful helper functions for interacting with various discord channel objects.""" -import disnake -from disnake.ext.commands import Bot +import discord +from discord.ext.commands import Bot from botcore.utils import logging log = logging.get_logger(__name__) -def is_in_category(channel: disnake.TextChannel, category_id: int) -> bool: +def is_in_category(channel: discord.TextChannel, category_id: int) -> bool: """ Return whether the given ``channel`` in the the category with the id ``category_id``. @@ -22,22 +22,22 @@ def is_in_category(channel: disnake.TextChannel, category_id: int) -> bool: return getattr(channel, "category_id", None) == category_id -async def get_or_fetch_channel(bot: Bot, channel_id: int) -> disnake.abc.GuildChannel: +async def get_or_fetch_channel(bot: Bot, channel_id: int) -> discord.abc.GuildChannel: """ Attempt to get or fetch the given ``channel_id`` from the bots cache, and return it. Args: - bot: The :obj:`disnake.ext.commands.Bot` instance to use for getting/fetching. + bot: The :obj:`discord.ext.commands.Bot` instance to use for getting/fetching. channel_id: The channel to get/fetch. Raises: - :exc:`disnake.InvalidData` + :exc:`discord.InvalidData` An unknown channel type was received from Discord. - :exc:`disnake.HTTPException` + :exc:`discord.HTTPException` Retrieving the channel failed. - :exc:`disnake.NotFound` + :exc:`discord.NotFound` Invalid Channel ID. - :exc:`disnake.Forbidden` + :exc:`discord.Forbidden` You do not have permission to fetch this channel. Returns: diff --git a/botcore/utils/extensions.py b/botcore/utils/extensions.py index 053a58dc..841120c9 100644 --- a/botcore/utils/extensions.py +++ b/botcore/utils/extensions.py @@ -28,7 +28,7 @@ def walk_extensions(module: types.ModuleType) -> frozenset[str]: module (types.ModuleType): The module to look for extensions in. Returns: - A set of strings that can be passed directly to :obj:`disnake.ext.commands.Bot.load_extension`. + A set of strings that can be passed directly to :obj:`discord.ext.commands.Bot.load_extension`. """ def on_error(name: str) -> NoReturn: diff --git a/botcore/utils/members.py b/botcore/utils/members.py index f4a30eca..e89b4618 100644 --- a/botcore/utils/members.py +++ b/botcore/utils/members.py @@ -1,27 +1,27 @@ -"""Useful helper functions for interactin with :obj:`disnake.Member` objects.""" +"""Useful helper functions for interactin with :obj:`discord.Member` objects.""" import typing -import disnake +import discord from botcore.utils import logging log = logging.get_logger(__name__) -async def get_or_fetch_member(guild: disnake.Guild, member_id: int) -> typing.Optional[disnake.Member]: +async def get_or_fetch_member(guild: discord.Guild, member_id: int) -> typing.Optional[discord.Member]: """ Attempt to get a member from cache; on failure fetch from the API. Returns: - The :obj:`disnake.Member` or :obj:`None` to indicate the member could not be found. + The :obj:`discord.Member` or :obj:`None` to indicate the member could not be found. """ if member := guild.get_member(member_id): log.trace(f"{member} retrieved from cache.") else: try: member = await guild.fetch_member(member_id) - except disnake.errors.NotFound: + except discord.errors.NotFound: log.trace(f"Failed to fetch {member_id} from API.") return None log.trace(f"{member} fetched from API.") @@ -29,28 +29,28 @@ async def get_or_fetch_member(guild: disnake.Guild, member_id: int) -> typing.Op async def handle_role_change( - member: disnake.Member, + member: discord.Member, coro: typing.Callable[..., typing.Coroutine], - role: disnake.Role + role: discord.Role ) -> None: """ Await the given ``coro`` with ``member`` as the sole argument. Handle errors that we expect to be raised from - :obj:`disnake.Member.add_roles` and :obj:`disnake.Member.remove_roles`. + :obj:`discord.Member.add_roles` and :obj:`discord.Member.remove_roles`. Args: member: The member to pass to ``coro``. - coro: This is intended to be :obj:`disnake.Member.add_roles` or :obj:`disnake.Member.remove_roles`. + coro: This is intended to be :obj:`discord.Member.add_roles` or :obj:`discord.Member.remove_roles`. """ try: await coro(role) - except disnake.NotFound: + except discord.NotFound: log.error(f"Failed to change role for {member} ({member.id}): member not found") - except disnake.Forbidden: + except discord.Forbidden: log.error( f"Forbidden to change role for {member} ({member.id}); " f"possibly due to role hierarchy" ) - except disnake.HTTPException as e: + except discord.HTTPException as e: log.error(f"Failed to change role for {member} ({member.id}): {e.status} {e.code}") diff --git a/docs/conf.py b/docs/conf.py index 6ea701e5..855a5856 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -130,7 +130,7 @@ extlinks = { # -- Options for intersphinx extension --------------------------------------- intersphinx_mapping = { "python": ("https://docs.python.org/3", None), - "disnake": ("https://docs.disnake.dev/en/latest/", None), + "discord": ("https://discordpy.readthedocs.io/en/master/", None), "aiohttp": ("https://docs.aiohttp.org/en/stable/", None), } |