Add support for Discord templates
This commit is contained in:
@ -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 ('*', '`', '_', '~', '|'))
|
||||
|
||||
|
Reference in New Issue
Block a user