mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-08 10:53:10 +00:00
Expose more information from partial invites, along with counts.
This adds the following information. * `PartialInviteGuild` to replace `Object` patching * `PartialInviteChannel` to replace `Object` patching * Invite.approximate_member_count and Invite.approximate_presence_count The new partial objects provide better documentation on what is expected when you fetch random invites. Fixes #1830
This commit is contained in:
@ -882,7 +882,7 @@ class Client:
|
||||
|
||||
# Invite management
|
||||
|
||||
async def get_invite(self, url):
|
||||
async def get_invite(self, url, *, with_counts=True):
|
||||
"""|coro|
|
||||
|
||||
Gets an :class:`Invite` from a discord.gg URL or ID.
|
||||
@ -890,13 +890,17 @@ class Client:
|
||||
Note
|
||||
------
|
||||
If the invite is for a guild you have not joined, the guild and channel
|
||||
attributes of the returned invite will be :class:`Object` with the names
|
||||
patched in.
|
||||
attributes of the returned :class:`Invite` will be :class:`PartialInviteGuild` and
|
||||
:class:`PartialInviteChannel` respectively.
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
url : str
|
||||
url: :class:`str`
|
||||
The discord invite ID or URL (must be a discord.gg URL).
|
||||
with_counts: :class:`bool`
|
||||
Whether to include count information in the invite. This fills the
|
||||
:attr:`Invite.approximate_member_count` and :attr:`Invite.approximate_presence_count`
|
||||
fields.
|
||||
|
||||
Raises
|
||||
-------
|
||||
@ -912,7 +916,7 @@ class Client:
|
||||
"""
|
||||
|
||||
invite_id = self._resolve_invite(url)
|
||||
data = await self.http.get_invite(invite_id)
|
||||
data = await self.http.get_invite(invite_id, with_counts=with_counts)
|
||||
return Invite.from_incomplete(state=self._connection, data=data)
|
||||
|
||||
async def delete_invite(self, invite):
|
||||
|
Reference in New Issue
Block a user