diff options
author | 2020-09-25 12:16:12 -0700 | |
---|---|---|
committer | 2020-09-25 12:16:12 -0700 | |
commit | 67bc58c1cc50fdf479274f4eb3e9f394363a7e6d (patch) | |
tree | 3bdb22a3ec30667816975e04e4bac361e26ff0a2 /bot/utils/converters.py | |
parent | Merge pull request #449 from gustavwilliam/ext-managment (diff) |
Make .bm handle embed-suppression syntax for message links <link>
[link] and [<link>] are also supported
Diffstat (limited to 'bot/utils/converters.py')
-rw-r--r-- | bot/utils/converters.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bot/utils/converters.py b/bot/utils/converters.py new file mode 100644 index 00000000..74a0b5b7 --- /dev/null +++ b/bot/utils/converters.py @@ -0,0 +1,15 @@ +import discord + +from discord.ext.commands.converter import MessageConverter + + +class BetterMessageConverter(MessageConverter): + """A converter that handles embed-suppressed links like <http://example.com>""" + async def convert(self, ctx, argument: str) -> discord.Message: + # It's possible to wrap a message in [<>] as well, and it's supported because its easy + if argument.startswith("[") and argument.endswith("]"): + argument = argument[1:-1] + if argument.startswith("<") and argument.endswith(">"): + argument = argument[1:-1] + + return await super().convert(ctx, argument) |