Bump discord.py to 1.7.0 (#4928)

* Bump discord.py, but to the git version for now

* Import GuildConverter from d.py and deprecate our implementation

* Import PartialMessageConverter in our commands extension

* Use newly added `Cog.has_error_handler()` rather than private method

* Update snowflake regex to use 20 as max length

See Rapptz/discord.py#6501

* Use new supported way for custom cooldown buckets

* Include group args in command signature

* Update code to use `Client.close()` over `Client.logout()`

* Add StageChannelConverter and StoreChannelConverter

* Fix AttributeError in licenseinfo
This commit is contained in:
jack1142
2021-04-05 21:33:19 +02:00
committed by GitHub
parent 9008410fa4
commit adda30cbee
13 changed files with 69 additions and 56 deletions

View File

@@ -35,7 +35,6 @@ if TYPE_CHECKING:
__all__ = [
"DictConverter",
"GuildConverter",
"UserInputOptional",
"NoParseOptional",
"TimedeltaConverter",
@@ -47,7 +46,7 @@ __all__ = [
_ = Translator("commands.converter", __file__)
ID_REGEX = re.compile(r"([0-9]{15,21})")
ID_REGEX = re.compile(r"([0-9]{15,20})")
# Taken with permission from
@@ -134,29 +133,46 @@ def parse_timedelta(
return None
class GuildConverter(discord.Guild):
class _GuildConverter(discord.Guild):
"""Converts to a `discord.Guild` object.
The lookup strategy is as follows (in order):
1. Lookup by ID.
2. Lookup by name.
.. deprecated-removed:: 3.4.8 60
``GuildConverter`` is now only provided within ``redbot.core.commands`` namespace.
"""
@classmethod
async def convert(cls, ctx: "Context", argument: str) -> discord.Guild:
match = ID_REGEX.fullmatch(argument)
return await dpy_commands.GuildConverter().convert(ctx, argument)
if match is None:
ret = discord.utils.get(ctx.bot.guilds, name=argument)
else:
guild_id = int(match.group(1))
ret = ctx.bot.get_guild(guild_id)
if ret is None:
raise BadArgument(_('Server "{name}" not found.').format(name=argument))
_GuildConverter.__name__ = "GuildConverter"
return ret
def __getattr__(name: str, *, stacklevel: int = 2) -> Any:
# Let me just say it one more time... This is awesome! (PEP-562)
if name == "GuildConverter":
# let's not waste time on importing this when we don't need it
# (and let's not put in the public API)
from redbot.core.utils._internal_utils import deprecated_removed
deprecated_removed(
"`GuildConverter` from `redbot.core.commands.converter` namespace",
"3.4.8",
60,
"Use `GuildConverter` from `redbot.core.commands` namespace instead.",
stacklevel=2,
)
return globals()["_GuildConverter"]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
def __dir__() -> List[str]:
return [*globals().keys(), "GuildConverter"]
# Below this line are a lot of lies for mypy about things that *end up* correct when