From b48f510e154e40b8ba3bef58e5c513fccf90c89c Mon Sep 17 00:00:00 2001 From: Zomatree <39768508+Zomatree@users.noreply.github.com> Date: Sat, 29 May 2021 05:15:46 +0100 Subject: Add invite targets for voice channel invites --- discord/invite.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'discord/invite.py') diff --git a/discord/invite.py b/discord/invite.py index 213ef5a4..8e60d1e8 100644 --- a/discord/invite.py +++ b/discord/invite.py @@ -30,6 +30,7 @@ from .utils import parse_time, snowflake_time, _get_as_snowflake from .object import Object from .mixins import Hashable from .enums import ChannelType, VerificationLevel, InviteTarget, try_enum +from .appinfo import PartialAppInfo __all__ = ( 'PartialInviteChannel', @@ -277,12 +278,18 @@ class Invite(Hashable): channel: Union[:class:`abc.GuildChannel`, :class:`Object`, :class:`PartialInviteChannel`] The channel the invite is for. + target_type: :class:`InviteTarget` + The type of target for the voice channel invite. + + .. versionadded:: 2.0 + target_user: Optional[:class:`User`] - The target of this invite in the case of stream invites. + The user whose stream to display for this invite, if any. .. versionadded:: 2.0 - target_type: :class:`InviteTarget` - The invite's target type. + + target_application: Optional[:class:`PartialAppInfo`] + The embedded application the invite targets, if any. .. versionadded:: 2.0 """ @@ -303,6 +310,7 @@ class Invite(Hashable): '_state', 'approximate_member_count', 'approximate_presence_count', + 'target_application', 'expires_at', ) @@ -328,7 +336,11 @@ class Invite(Hashable): self.channel = data.get('channel') target_user_data = data.get('target_user') self.target_user = None if target_user_data is None else self._state.store_user(target_user_data) - self.target_type = try_enum(InviteTarget, data.get('target_type', 0)) + + self.target_type = try_enum(InviteTarget, data.get("target_type", 0)) + + application = data.get('target_application') + self.target_application = PartialAppInfo(data=application, state=state) if application else None @classmethod def from_incomplete(cls, *, state, data): -- cgit v1.2.3