Skip to content

Commit 7489f6f

Browse files
feat: Add missing attributes when creating an invite (#606)
* fix: fix Invite model missing attributes + adding docstring * ci: correct from checks. * fix: Implement missing attributes when creating an invite * ci: correct from checks. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ce4069f commit 7489f6f

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

interactions/api/models/guild.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,9 +1582,14 @@ class Invite(DictSerializerMixin):
15821582
:ivar datetime expires_at: The time when this invite will expire.
15831583
:ivar int type: The type of this invite.
15841584
:ivar User inviter: The user who created this invite.
1585-
:ivar int guild_id: The guild ID of this invite.
15861585
:ivar str code: The code of this invite.
1587-
:ivar int channel_id: The channel ID of this invite.
1586+
:ivar Optional[int] guild_id: The guild ID of this invite.
1587+
:ivar Optional[int] channel_id: The channel ID of this invite.
1588+
:ivar Optional[int] target_user_type: The type of the target user of this invite.
1589+
:ivar Optional[User] target_user: The target user of this invite.
1590+
:ivar Optional[int] target_type: The target type of this invite.
1591+
:ivar Optional[Guild] guild: The guild of this invite.
1592+
:ivar Optional[Channel] channel: The channel of this invite.
15881593
"""
15891594

15901595
__slots__ = (
@@ -1601,6 +1606,11 @@ class Invite(DictSerializerMixin):
16011606
"expires_at",
16021607
"code",
16031608
"channel_id",
1609+
"target_user_type",
1610+
"target_user",
1611+
"target_type",
1612+
"guild",
1613+
"channel",
16041614
)
16051615

16061616
def __init__(self, **kwargs):
@@ -1616,8 +1626,21 @@ def __init__(self, **kwargs):
16161626
else None
16171627
)
16181628
self.inviter = User(**self._json.get("inviter")) if self._json.get("inviter") else None
1619-
self.channel_id = int(self.channel_id)
1620-
self.guild_id = int(self.guild_id)
1629+
self.channel_id = int(self.channel_id) if self._json.get("channel_id") else None
1630+
self.guild_id = int(self.guild_id) if self._json.get("guild_id") else None
1631+
self.target_user = (
1632+
User(**self._json.get("target_user")) if self._json.get("target_user") else None
1633+
)
1634+
self.guild = (
1635+
Guild(**self._json.get("guild"), _client=self._client)
1636+
if self._json.get("guild")
1637+
else None
1638+
)
1639+
self.channel = (
1640+
Channel(**self._json.get("channel"), _client=self._client)
1641+
if self._json.get("channel")
1642+
else None
1643+
)
16211644

16221645

16231646
class GuildTemplate(DictSerializerMixin):

0 commit comments

Comments
 (0)