From 2b3c6e0d4776fae080191e605c2caf89fa132e1b Mon Sep 17 00:00:00 2001 From: Nadir Chowdhury Date: Sun, 28 Jun 2020 19:48:04 +0100 Subject: Add support for Discord templates --- discord/utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'discord/utils.py') diff --git a/discord/utils.py b/discord/utils.py index 118b4691..9c4bd43a 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -451,6 +451,17 @@ def resolve_invite(invite): return m.group(1) return invite +def resolve_template(code): + from .template import Template # circular import + if isinstance(code, (Template, Object)): + return template.id + else: + rx = r'(?:https?\:\/\/)?discord(?:\.new|(?:app)?\.com\/template)\/(.+)' + m = re.match(rx, code) + if m: + return m.group(1) + return code + _MARKDOWN_ESCAPE_SUBREGEX = '|'.join(r'\{0}(?=([\s\S]*((?