From 76a4b8df94371ca8e9dce4caabf6851560716141 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 27 Dec 2019 23:37:41 +0000 Subject: [PATCH] Add new invite fields for go live and guild counts. (#159) * Go live invite support. * url params to invites get rather than json. --- disco/api/client.py | 4 ++-- disco/types/invite.py | 36 ++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/disco/api/client.py b/disco/api/client.py index 313a4bb..45367ff 100644 --- a/disco/api/client.py +++ b/disco/api/client.py @@ -634,8 +634,8 @@ class APIClient(LoggingClass): r = self.http(Routes.USERS_ME_CONNECTIONS_LIST) return Connection.create_map(self.client, r.json()) - def invites_get(self, invite): - r = self.http(Routes.INVITES_GET, dict(invite=invite)) + def invites_get(self, invite, with_counts=None): + r = self.http(Routes.INVITES_GET, dict(invite=invite), params=optional(with_counts=with_counts)) return Invite.create(self.client, r.json()) def invites_delete(self, invite, reason=None): diff --git a/disco/types/invite.py b/disco/types/invite.py index 1d44b3e..4df6939 100644 --- a/disco/types/invite.py +++ b/disco/types/invite.py @@ -1,9 +1,13 @@ -from disco.types.base import SlottedModel, Field, datetime +from disco.types.base import SlottedModel, Field, datetime, enum from disco.types.user import User from disco.types.guild import Guild from disco.types.channel import Channel +class InviteTargetUserType(object): + STREAM = 1 + + class Invite(SlottedModel): """ An invite object. @@ -12,30 +16,42 @@ class Invite(SlottedModel): ---------- code : str The invite code. - inviter : :class:`disco.types.user.User` - The user who created this invite. guild : :class:`disco.types.guild.Guild` The guild this invite is for. channel : :class:`disco.types.channel.Channel` The channel this invite is for. - max_age : int - The time after this invite's creation at which it expires. - max_uses : int - The maximum number of uses. + target_user : :class:`disco.types.user.User` + The user this invite targets. + target_user_type : int + The type of user target for this invite. + approximate_presence_count : int + The approximate count of online members. + approximate_member_count : int + The approximate count of total members. + inviter : :class:`disco.types.user.User` + The user who created this invite. uses : int The current number of times the invite was used. + max_uses : int + The maximum number of uses. + max_age : int + The time after this invite's creation at which it expires. temporary : bool Whether this invite only grants temporary membership. created_at : datetime When this invite was created. """ code = Field(str) - inviter = Field(User) guild = Field(Guild) channel = Field(Channel) - max_age = Field(int) - max_uses = Field(int) + target_user = Field(User) + target_user_type = Field(enum(InviteTargetUserType)) + approximate_presence_count = Field(int) + approximate_member_count = Field(int) + inviter = Field(User) uses = Field(int) + max_uses = Field(int) + max_age = Field(int) temporary = Field(bool) created_at = Field(datetime)