From c54d6f03c5b63f7eca492da80d90dccd366e15e3 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra Date: Tue, 3 Nov 2020 16:07:38 +0100 Subject: [PATCH] [commands] Update MessageConverter link regex Remove redundant parts of the MessageConverter regexes and support www --- discord/ext/commands/converter.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 155b1a4e2..adec41dcd 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[0-9]{15,21})-)?(?P[0-9]{15,21})$') + id_regex = re.compile(r'(?:(?P[0-9]{15,21})-)?(?P[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[0-9]{15,21})/(?P[0-9]{15,21})/?$' ) match = id_regex.match(argument) or link_regex.match(argument)