aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael H <[email protected]>2021-04-05 21:39:17 -0400
committerGitHub <[email protected]>2021-04-05 21:39:17 -0400
commit682b73abb632dfdfb687464d0665e76e571f0f6f (patch)
tree0f8467dd47e8adb7f8d99e15012702e6c7dfbd47
parent[commands] Add more type information to public API of converters (diff)
downloaddiscord.py-682b73abb632dfdfb687464d0665e76e571f0f6f.tar.xz
discord.py-682b73abb632dfdfb687464d0665e76e571f0f6f.zip
[commands] Address incorrect use of subclass (from type perspective)
This is a follow up from #6641
-rw-r--r--discord/ext/commands/converter.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py
index 1157334a..f9a8592c 100644
--- a/discord/ext/commands/converter.py
+++ b/discord/ext/commands/converter.py
@@ -263,7 +263,7 @@ class UserConverter(IDConverter[discord.User]):
return result
-class PartialMessageConverter(IDConverter[discord.PartialMessage], Generic[T]):
+class PartialMessageConverter(Converter[discord.PartialMessage]):
"""Converts to a :class:`discord.PartialMessage`.
.. versionadded:: 1.7
@@ -274,7 +274,8 @@ class PartialMessageConverter(IDConverter[discord.PartialMessage], Generic[T]):
2. By message ID (The message is assumed to be in the context channel.)
3. By message URL
"""
- def _get_id_matches(self, argument):
+ @staticmethod
+ def _get_id_matches(argument):
id_regex = re.compile(r'(?:(?P<channel_id>[0-9]{15,20})-)?(?P<message_id>[0-9]{15,20})$')
link_regex = re.compile(
r'https?://(?:(ptb|canary|www)\.)?discord(?:app)?\.com/channels/'
@@ -294,7 +295,7 @@ class PartialMessageConverter(IDConverter[discord.PartialMessage], Generic[T]):
raise ChannelNotFound(channel_id)
return discord.PartialMessage(channel=channel, id=message_id)
-class MessageConverter(PartialMessageConverter[discord.Message]):
+class MessageConverter(IDConverter[discord.Message]):
"""Converts to a :class:`discord.Message`.
.. versionadded:: 1.1
@@ -309,7 +310,7 @@ class MessageConverter(PartialMessageConverter[discord.Message]):
Raise :exc:`.ChannelNotFound`, :exc:`.MessageNotFound` or :exc:`.ChannelNotReadable` instead of generic :exc:`.BadArgument`
"""
async def convert(self, ctx: Context, argument: str) -> discord.Message:
- message_id, channel_id = self._get_id_matches(argument)
+ message_id, channel_id = PartialMessageConverter._get_id_matches(argument)
message = ctx.bot._connection._get_message(message_id)
if message:
return message