diff options
author | 2020-09-29 23:30:35 -0400 | |
---|---|---|
committer | 2020-09-29 23:30:35 -0400 | |
commit | db35ee8c090702256a7b72b75e630ef58859e719 (patch) | |
tree | 4ccf8e2924c7950e534c6f22d43dcded8ef7b4e1 /bot/utils/converters.py | |
parent | PR #458 Deps: update Pillow to 7.2 (diff) | |
parent | Merge branch 'master' into fix-bast-linkwrap-syntax (diff) |
Merge pull request #459 from bast0006/fix-bast-linkwrap-syntax
Make .bm handle embed-suppression syntax for message links
Diffstat (limited to 'bot/utils/converters.py')
-rw-r--r-- | bot/utils/converters.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bot/utils/converters.py b/bot/utils/converters.py new file mode 100644 index 00000000..228714c9 --- /dev/null +++ b/bot/utils/converters.py @@ -0,0 +1,16 @@ +import discord +from discord.ext.commands.converter import MessageConverter + + +class WrappedMessageConverter(MessageConverter): + """A converter that handles embed-suppressed links like <http://example.com>.""" + + async def convert(self, ctx: discord.ext.commands.Context, argument: str) -> discord.Message: + """Wrap the commands.MessageConverter to handle <> delimited message links.""" + # 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) |