Browse Source

[docs] fix reference to `Guild` and document `utils.resolve_template`

pull/5120/head
NCPlayz 5 years ago
committed by Rapptz
parent
commit
3408695a37
  1. 4
      discord/template.py
  2. 19
      discord/utils.py
  3. 2
      docs/api.rst

4
discord/template.py

@ -84,7 +84,7 @@ class Template:
code: :class:`str`
The template code.
uses: :class:`int`
How many time the template has been used.
How many times the template has been used.
name: :class:`str`
The name of the template.
description: :class:`str`
@ -95,7 +95,7 @@ class Template:
When the template was created.
updated_at: :class:`datetime.datetime`
When the template was last updated (referred to as "last synced" in the client).
source_guild: :class:`TemplateGuild`
source_guild: :class:`Guild`
The source guild.
"""

19
discord/utils.py

@ -429,11 +429,11 @@ def _string_width(string, *, _IS_ASCII=_IS_ASCII):
def resolve_invite(invite):
"""
Resolves an invite from a :class:`~discord.Invite`, URL or ID
Resolves an invite from a :class:`~discord.Invite`, URL or code.
Parameters
-----------
invite: Union[:class:`~discord.Invite`, :class:`~discord.Object`, :class:`str`]
invite: Union[:class:`~discord.Invite`, :class:`str`]
The invite.
Returns
@ -452,6 +452,21 @@ def resolve_invite(invite):
return invite
def resolve_template(code):
"""
Resolves a template code from a :class:`~discord.Template`, URL or code.
.. versionadded:: 1.4
Parameters
-----------
code: Union[:class:`~discord.Template`, :class:`str`]
The code.
Returns
--------
:class:`str`
The template code.
"""
from .template import Template # circular import
if isinstance(code, Template):
return template.code

2
docs/api.rst

@ -729,6 +729,8 @@ Utility Functions
.. autofunction:: discord.utils.resolve_invite
.. autofunction:: discord.utils.resolve_template
.. autofunction:: discord.utils.sleep_until
Profile

Loading…
Cancel
Save