diff options
| author | 2020-11-30 15:18:42 +0100 | |
|---|---|---|
| committer | 2020-11-30 15:18:42 +0100 | |
| commit | 0ad849431eee3cab48485a132df23b0883142cf6 (patch) | |
| tree | d9bd17fbd8f22c45e682079f6e3e565b6e17f61d /bot/utils/converters.py | |
| parent | "adding xkcd feature" (diff) | |
| parent | Merge pull request #532 from python-discord/sebastiaan/ci/add-core-dev-approv... (diff) | |
Merge branch 'master' into issue-337
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) |