From 1a697457b7ceb5ccb329eb30044dd5bb962b03d2 Mon Sep 17 00:00:00 2001 From: Zomatree Date: Mon, 11 Sep 2023 15:53:54 +0100 Subject: [PATCH] Fix member.edit --- revolt/channel.py | 3 ++- revolt/member.py | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/revolt/channel.py b/revolt/channel.py index 5b2a8b5..c32e91c 100755 --- a/revolt/channel.py +++ b/revolt/channel.py @@ -133,7 +133,8 @@ class DMChannel(Channel, Messageable): def __init__(self, data: DMChannelPayload, state: State): super().__init__(data, state) - self.recipient_ids: tuple[str, str] = tuple(data["recipients"]) + + self.recipient_ids: list[str] = data["recipients"] self.last_message_id: str | None = data.get("last_message_id") @property diff --git a/revolt/member.py b/revolt/member.py index 741dc50..533c494 100755 --- a/revolt/member.py +++ b/revolt/member.py @@ -134,6 +134,19 @@ class Member(User): avatar: File | None | _Missing = Missing, timeout: datetime.timedelta | None | _Missing = Missing ) -> None: + """Edits the member + + Parameters + ----------- + nickname: Union[:class:`str`, :class:`None`] + The new nickname, or :class:`None` to reset it + roles: Union[list[:class:`Role`], :class:`None`] + The new roles for the member, or :class:`None` to clear it + avatar: Union[:class:`File`, :class:`None`] + The new server avatar, or :class:`None` to reset it + timeout: Union[:class:`datetime.timedelta`, :class:`None`] + The new timeout length for the member, or :class:`None` to reset it + """ remove: list[str] = [] data: dict[str, Any] = {} @@ -144,21 +157,17 @@ class Member(User): if roles is None: remove.append("Roles") - elif roles is not Missing: - data["roles"] = roles + elif not isinstance(roles, _Missing): + data["roles"] = [role.id for role in roles] if avatar is None: remove.append("Avatar") - elif avatar is not Missing: - # pyright cant understand custom singletons - it doesnt know this will never be an instance of _Missing here because Missing is the only instance - assert not isinstance(avatar, _Missing) - + elif not isinstance(avatar, _Missing): data["avatar"] = (await self.state.http.upload_file(avatar, "avatars"))["id"] if timeout is None: remove.append("Timeout") - elif timeout is not Missing: - assert not isinstance(timeout, _Missing) + elif not isinstance(timeout, _Missing): data["timeout"] = (datetime.datetime.now(datetime.timezone.utc) + timeout).isoformat() await self.state.http.edit_member(self.server.id, self.id, remove, data)