Add fetch_invite with with_expiration

This commit is contained in:
Nadir Chowdhury
2021-05-01 12:46:16 +01:00
committed by GitHub
parent 4fcbe75d3b
commit e762f55847
3 changed files with 37 additions and 20 deletions

View File

@ -1132,7 +1132,7 @@ class Client:
# Invite management
async def fetch_invite(self, url: Union[Invite, str], *, with_counts: bool = True) -> Invite:
async def fetch_invite(self, url: Union[Invite, str], *, with_counts: bool = True, with_expiration: bool = True) -> Invite:
"""|coro|
Gets an :class:`.Invite` from a discord.gg URL or ID.
@ -1151,6 +1151,11 @@ class Client:
Whether to include count information in the invite. This fills the
:attr:`.Invite.approximate_member_count` and :attr:`.Invite.approximate_presence_count`
fields.
with_expiration: :class:`bool`
Whether to include the expiration date of the invite. This fills the
:attr:`.Invite.expires_at` field.
.. versionadded:: 2.0
Raises
-------
@ -1166,7 +1171,7 @@ class Client:
"""
invite_id = utils.resolve_invite(url)
data = await self.http.get_invite(invite_id, with_counts=with_counts)
data = await self.http.get_invite(invite_id, with_counts=with_counts, with_expiration=with_expiration)
return Invite.from_incomplete(state=self._connection, data=data)
async def delete_invite(self, invite: Union[Invite, str]) -> None: