From 67abfea61a0f5de45ef3d76975bf702e4b016b82 Mon Sep 17 00:00:00 2001 From: sudosnok Date: Thu, 22 Apr 2021 04:30:35 +0100 Subject: Add target_user and target_type to Invite objects --- discord/enums.py | 6 ++++++ discord/invite.py | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'discord') diff --git a/discord/enums.py b/discord/enums.py index bf1a3115..0d7305ba 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -46,6 +46,7 @@ __all__ = ( 'ExpireBehaviour', 'ExpireBehavior', 'StickerType', + 'InviteTarget', 'VideoQualityMode', ) @@ -426,6 +427,11 @@ class StickerType(Enum): apng = 2 lottie = 3 +class InviteTarget(Enum): + unknown = 0 + stream = 1 + embedded_application = 2 + class InteractionType(Enum): ping = 1 application_command = 2 diff --git a/discord/invite.py b/discord/invite.py index c4e88ba2..95fcb0b7 100644 --- a/discord/invite.py +++ b/discord/invite.py @@ -29,7 +29,7 @@ from .asset import Asset from .utils import parse_time, snowflake_time, _get_as_snowflake from .object import Object from .mixins import Hashable -from .enums import ChannelType, VerificationLevel, try_enum +from .enums import ChannelType, VerificationLevel, InviteTarget, try_enum __all__ = ( 'PartialInviteChannel', @@ -269,6 +269,14 @@ class Invite(Hashable): This includes idle, dnd, online, and invisible members. Offline members are excluded. channel: Union[:class:`abc.GuildChannel`, :class:`Object`, :class:`PartialInviteChannel`] The channel the invite is for. + target_user: Optional[:class:`User`] + The target of this invite in the case of stream invites. + + .. versionadded:: 2.0 + target_type: :class:`InviteType` + The invite's target type. + + .. versionadded:: 2.0 """ __slots__ = ( @@ -282,6 +290,8 @@ class Invite(Hashable): 'max_uses', 'inviter', 'channel', + 'target_user', + 'target_type', '_state', 'approximate_member_count', 'approximate_presence_count', @@ -305,6 +315,9 @@ class Invite(Hashable): inviter_data = data.get('inviter') self.inviter = None if inviter_data is None else self._state.store_user(inviter_data) 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)) @classmethod def from_incomplete(cls, *, state, data): -- cgit v1.2.3