aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Feenstra <[email protected]>2020-11-03 16:07:38 +0100
committerRapptz <[email protected]>2020-11-21 21:30:54 -0500
commitc54d6f03c5b63f7eca492da80d90dccd366e15e3 (patch)
tree6e99c30f2f499e351b49997ada999806e0317dc0
parentRaise ClientException when members intent is not enabled on guild.fetch_members (diff)
downloaddiscord.py-c54d6f03c5b63f7eca492da80d90dccd366e15e3.tar.xz
discord.py-c54d6f03c5b63f7eca492da80d90dccd366e15e3.zip
[commands] Update MessageConverter link regex
Remove redundant parts of the MessageConverter regexes and support www
-rw-r--r--discord/ext/commands/converter.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py
index 155b1a4e..adec41dc 100644
--- a/discord/ext/commands/converter.py
+++ b/discord/ext/commands/converter.py
@@ -254,12 +254,11 @@ class MessageConverter(Converter):
.. versionchanged:: 1.5
Raise :exc:`.ChannelNotFound`, `MessageNotFound` or `ChannelNotReadable` instead of generic :exc:`.BadArgument`
"""
-
async def convert(self, ctx, argument):
- id_regex = re.compile(r'^(?:(?P<channel_id>[0-9]{15,21})-)?(?P<message_id>[0-9]{15,21})$')
+ id_regex = re.compile(r'(?:(?P<channel_id>[0-9]{15,21})-)?(?P<message_id>[0-9]{15,21})$')
link_regex = re.compile(
- r'^https?://(?:(ptb|canary)\.)?discord(?:app)?\.com/channels/'
- r'(?:([0-9]{15,21})|(@me))'
+ r'https?://(?:(ptb|canary|www)\.)?discord(?:app)?\.com/channels/'
+ r'(?:[0-9]{15,21}|@me)'
r'/(?P<channel_id>[0-9]{15,21})/(?P<message_id>[0-9]{15,21})/?$'
)
match = id_regex.match(argument) or link_regex.match(argument)