diff options
| author | Rapptz <[email protected]> | 2019-02-12 20:21:29 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-02-12 20:22:47 -0500 |
| commit | 5d78f43e558cdd55e22eb12a090d3d75fd258a8e (patch) | |
| tree | 9485cf47c706eef9eb315c897e589702423a697a /discord/client.py | |
| parent | Bump aiohttp requirement and fix AsyncWebhookAdapter (diff) | |
| download | discord.py-5d78f43e558cdd55e22eb12a090d3d75fd258a8e.tar.xz discord.py-5d78f43e558cdd55e22eb12a090d3d75fd258a8e.zip | |
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
Diffstat (limited to 'discord/client.py')
| -rw-r--r-- | discord/client.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/discord/client.py b/discord/client.py index f832efcc..26e22df9 100644 --- a/discord/client.py +++ b/discord/client.py @@ -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): |