Browse Source

Give ext.commands some love

pull/10109/head
dolfies 4 years ago
parent
commit
4c2d9bc0d0
  1. 4
      discord/ext/commands/bot.py
  2. 5
      discord/ext/commands/context.py
  3. 2
      discord/ext/commands/converter.py
  4. 3
      discord/ext/commands/help.py

4
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.

5
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:

2
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

3
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

Loading…
Cancel
Save