diff options
| author | Nadir Chowdhury <[email protected]> | 2020-06-28 19:48:04 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-06-28 14:48:04 -0400 |
| commit | 2b3c6e0d4776fae080191e605c2caf89fa132e1b (patch) | |
| tree | dd870ce057115cd852d59749092709caee2b4d78 /discord/utils.py | |
| parent | [commands] Raise TypeError when Optional is used with Greedy converter (diff) | |
| download | discord.py-2b3c6e0d4776fae080191e605c2caf89fa132e1b.tar.xz discord.py-2b3c6e0d4776fae080191e605c2caf89fa132e1b.zip | |
Add support for Discord templates
Diffstat (limited to 'discord/utils.py')
| -rw-r--r-- | discord/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
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]*((?<!\{0})\{0})))'.format(c) for c in ('*', '`', '_', '~', '|')) |