Skip to content

Commit

Permalink
Member.joined_at can now be None
Browse files Browse the repository at this point in the history
Discord making breaking changes :D
  • Loading branch information
davfsa committed Jan 21, 2024
1 parent 5436026 commit 14cf736
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changes/1812.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`Member.joined_at` is now nullable due to breaking API change
- This will be received on guest members with temporary membership
8 changes: 6 additions & 2 deletions hikari/guilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,12 @@ class Member(users.User):
This will be `hikari.undefined.UNDEFINED` if it's state is unknown.
"""

joined_at: datetime.datetime = attrs.field(repr=True)
"""The datetime of when this member joined the guild they belong to."""
joined_at: typing.Optional[datetime.datetime] = attrs.field(repr=True)
"""The datetime of when this member joined the guild they belong to.
This will be `None` for guest members that have been temporarily
invited.
"""

nickname: typing.Optional[str] = attrs.field(repr=True)
"""This member's nickname.
Expand Down
3 changes: 2 additions & 1 deletion hikari/impl/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,8 @@ def deserialize_member(
if guild_id not in role_ids:
role_ids.append(guild_id)

joined_at = time.iso8601_datetime_string_to_datetime(payload["joined_at"])
raw_joined_at = payload["joined_at"]
joined_at = time.iso8601_datetime_string_to_datetime(raw_joined_at) if raw_joined_at is not None else None

raw_premium_since = payload.get("premium_since")
premium_since = (
Expand Down
3 changes: 2 additions & 1 deletion tests/hikari/impl/test_entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3230,7 +3230,7 @@ def test_deserialize_member_with_null_fields(self, entity_factory_impl, user_pay
{
"nick": None,
"roles": ["11111", "22222", "33333", "44444"],
"joined_at": "2015-04-26T06:26:56.936000+00:00",
"joined_at": None,
"premium_since": None,
"deaf": False,
"avatar": None,
Expand All @@ -3244,6 +3244,7 @@ def test_deserialize_member_with_null_fields(self, entity_factory_impl, user_pay
assert member.nickname is None
assert member.premium_since is None
assert member.guild_avatar_hash is None
assert member.joined_at is None
assert isinstance(member, guild_models.Member)

def test_deserialize_member_with_undefined_fields(self, entity_factory_impl, user_payload):
Expand Down

0 comments on commit 14cf736

Please sign in to comment.