From 4c2d9bc0d09dd2485af9f52cbf172da92c03dc0c Mon Sep 17 00:00:00 2001 From: dolfies Date: Wed, 24 Nov 2021 20:18:20 -0500 Subject: [PATCH] Give ext.commands some love --- discord/ext/commands/bot.py | 4 ++-- discord/ext/commands/context.py | 5 ++--- discord/ext/commands/converter.py | 2 +- discord/ext/commands/help.py | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index 0c14c5389..e334394b2 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -65,7 +65,7 @@ T = TypeVar('T') CFT = TypeVar('CFT', bound='CoroFunc') CXT = TypeVar('CXT', bound='Context') -def when_mentioned(bot: Union[Bot, AutoShardedBot], msg: Message) -> List[str]: +def when_mentioned(bot: Bot, msg: Message) -> List[str]: """A callable that implements a command prefix equivalent to being mentioned. These are meant to be passed into the :attr:`.Bot.command_prefix` attribute. @@ -73,7 +73,7 @@ def when_mentioned(bot: Union[Bot, AutoShardedBot], msg: Message) -> List[str]: # bot.user will never be None when this is called return [f'<@{bot.user.id}> ', f'<@!{bot.user.id}> '] # type: ignore -def when_mentioned_or(*prefixes: str) -> Callable[[Union[Bot, AutoShardedBot], Message], List[str]]: +def when_mentioned_or(*prefixes: str) -> Callable[[Bot, Message], List[str]]: """A callable that implements when mentioned or other prefixes provided. These are meant to be passed into the :attr:`.Bot.command_prefix` attribute. diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index 38a24d1db..c4027ed0b 100644 --- a/discord/ext/commands/context.py +++ b/discord/ext/commands/context.py @@ -43,10 +43,9 @@ if TYPE_CHECKING: from discord.user import ClientUser, User from discord.voice_client import VoiceProtocol - from .bot import Bot, AutoShardedBot + from .bot import Bot from .cog import Cog from .core import Command - from .help import HelpCommand from .view import StringView __all__ = ( @@ -57,7 +56,7 @@ MISSING: Any = discord.utils.MISSING T = TypeVar('T') -BotT = TypeVar('BotT', bound="Union[Bot, AutoShardedBot]") +BotT = TypeVar('BotT', bound="Bot") CogT = TypeVar('CogT', bound="Cog") if TYPE_CHECKING: diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 5740a188e..834bfc58c 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -201,7 +201,7 @@ class MemberConverter(IDConverter[discord.Member]): return discord.utils.find(lambda m: m.name == argument or m.nick == argument, members) async def query_member_by_id(self, bot, guild, user_id): - ws = bot._get_websocket(shard_id=guild.shard_id) + ws = bot.ws cache = guild._state.member_cache_flags.joined if ws.is_ratelimited(): # If we're being rate limited on the WS, then fall back to using the HTTP API diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py index afaacbfb2..49f8f768d 100644 --- a/discord/ext/commands/help.py +++ b/discord/ext/commands/help.py @@ -25,10 +25,9 @@ DEALINGS IN THE SOFTWARE. import itertools import copy import functools -import inspect import re -from typing import Optional, TYPE_CHECKING +from typing import TYPE_CHECKING import discord.utils