diff options
| author | Rapptz <[email protected]> | 2021-08-23 23:46:50 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-08-23 23:46:50 -0400 |
| commit | 490bbffc935856f885edd9a2d1505ac228c38f72 (patch) | |
| tree | 46a2aa80b6ebbe1faddd3ddd8c338cce1e8eb613 /discord/member.py | |
| parent | Fix typing of move role position payload parameter (diff) | |
| download | discord.py-490bbffc935856f885edd9a2d1505ac228c38f72.tar.xz discord.py-490bbffc935856f885edd9a2d1505ac228c38f72.zip | |
Remove in-place edits and return fresh instances instead
Fixes #4098
Diffstat (limited to 'discord/member.py')
| -rw-r--r-- | discord/member.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/discord/member.py b/discord/member.py index fddec8ce..1ff682c4 100644 --- a/discord/member.py +++ b/discord/member.py @@ -644,7 +644,7 @@ class Member(discord.abc.Messageable, _UserTag): roles: List[discord.abc.Snowflake] = MISSING, voice_channel: Optional[VocalGuildChannel] = MISSING, reason: Optional[str] = None, - ) -> None: + ) -> Optional[Member]: """|coro| Edits the member's data. @@ -670,6 +670,9 @@ class Member(discord.abc.Messageable, _UserTag): .. versionchanged:: 1.1 Can now pass ``None`` to ``voice_channel`` to kick a member from voice. + .. versionchanged:: 2.0 + The newly member is now optionally returned, if applicable. + Parameters ----------- nick: Optional[:class:`str`] @@ -697,6 +700,12 @@ class Member(discord.abc.Messageable, _UserTag): You do not have the proper permissions to the action requested. HTTPException The operation failed. + + Returns + -------- + Optional[:class:`.Member`] + The newly updated member, if applicable. This is only returned + when certain fields are updated. """ http = self._state.http guild_id = self.guild.id @@ -739,7 +748,8 @@ class Member(discord.abc.Messageable, _UserTag): payload['roles'] = tuple(r.id for r in roles) if payload: - await http.edit_member(guild_id, self.id, reason=reason, **payload) + data = await http.edit_member(guild_id, self.id, reason=reason, **payload) + return Member(data=data, guild=self.guild, state=self._state) async def request_to_speak(self) -> None: """|coro| |