aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/converters.py
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2020-10-04 10:57:43 +0200
committerGravatar GitHub <[email protected]>2020-10-04 10:57:43 +0200
commit3128fdb134fb8e73c83f88fa1b7e08499a0a6d8c (patch)
treed3f5b25f85821828e5c825163f3d03ac3487a94e /bot/utils/converters.py
parentremoved tag handling (diff)
parentMerge pull request #473 from Anubhav1603/ec (diff)
Merge branch 'master' into source_cmd
Diffstat (limited to 'bot/utils/converters.py')
-rw-r--r--bot/utils/converters.py16
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)