Repository: Rapptz/discord.py

Issue:
target_user and target_user_type in invite objects
### The Problem
target_user and target_user_type are given by the api but are not in invite objects
https://discordapp.com/developers/docs/resources/invite#invite-object-invite-structure

### The Ideal Solution

Adding target_user and target_user_type to invite objects

### The Current Solution

Using raw http calls

### Summary
target_user and target_user_type were added for stream invites but have not been added to discord.py



Discussion:
Is this not the [Invite.inviter](https://discordpy.readthedocs.io/en/latest/api.html#discord.Invite.inviter) attribute?
No, target_user is the user the invite is targeted at; the invite can be made by people other than the target_user.
Atm the only thing using this are stream invites which can be made by anyone watching the stream.
Example:
```
{
    "code": "URy9TF",
    "guild": {
        "id": "536702243119038464",
        "name": "SF e&c",
        "splash": null,
        "banner": null,
        "description": null,
        "icon": null,
        "features": [],
        "verification_level": 0,
        "vanity_url_code": null
    },
    "channel": {
        "id": "618596987209646102",
        "name": "Streams",
        "type": 2
    },
    "inviter": {
        "id": "145897775274524672",
        "username": "Jay",
        "avatar": "8bb5ef9e91bf154bb8bee183f48d9d5e",
        "discriminator": "4707"
    },
    "target_user": {
        "id": "285148358815776768",
        "username": "StarrFox",
        "avatar": "f23b50a67ed78dcbef77d56b14e9f56f",
        "discriminator": "6312"
    },
    "target_user_type": 1,
    "approximate_member_count": 55,
    "approximate_presence_count": 28
}
```

Resolving patch:
diff --git a/discord/enums.py b/discord/enums.py
--- a/discord/enums.py
+++ b/discord/enums.py
@@ -46,6 +46,7 @@
     'ExpireBehaviour',
     'ExpireBehavior',
     'StickerType',
+    'InviteTarget',
     'VideoQualityMode',
 )
 
@@ -425,6 +426,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
--- a/discord/invite.py
+++ b/discord/invite.py
@@ -29,7 +29,7 @@
 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 @@ def __init__(self, *, state, data: InvitePayload):
         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):


Test patch: