Repository: Rapptz/discord.py
File: discord/member.py (Python)

Code before:
        reason: Optional[:class:`str`]
            The reason for editing this member. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You do not have the proper permissions to do the action requested.
        HTTPException
            The operation failed.
        TypeError
            The datetime object passed to ``timed_out_until`` was not timezone-aware.
        ValueError
            You tried to edit the bio, avatar or banner of a member that is not the bot's own member.
            Or the wrong image format passed for ``avatar`` or ``banner``.

        Returns
        --------
        Optional[:class:`.Member`]
            The newly updated member, if applicable. This is not returned
            if certain fields are passed, such as ``suppress``.
        """
        http = self._state.http
        guild_id = self.guild.id
        me = self._state.self_id == self.id
        payload: Dict[str, Any] = {}
        bot_payload: Dict[str, Any] = {}

        if nick is not MISSING:
            nick = nick or ''
            if me:
                bot_payload['nick'] = nick
            else:
                payload['nick'] = nick

        if avatar is not MISSING:
            if avatar is None:
                bot_payload['avatar'] = None
            else:
                bot_payload['avatar'] = utils._bytes_to_base64_data(avatar)

        if banner is not MISSING:
            if banner is None:
                bot_payload['banner'] = None
            else:
                bot_payload['banner'] = utils._bytes_to_base64_data(banner)

        if bio is not MISSING:
            bot_payload['bio'] = bio or ''

        if not me and bot_payload:
            raise ValueError(f"Editing the bio, avatar or banner is only for the bot's own member.")

Review comment (suggestion):
Rename this to `self_payload` since it's a little bit clearer for me.

Code after:
        reason: Optional[:class:`str`]
            The reason for editing this member. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You do not have the proper permissions to do the action requested.
        HTTPException
            The operation failed.
        TypeError
            The datetime object passed to ``timed_out_until`` was not timezone-aware.
        ValueError
            You tried to edit the bio, avatar or banner of a member that is not the bot's own member.
            Or the wrong image format passed for ``avatar`` or ``banner``.

        Returns
        --------
        Optional[:class:`.Member`]
            The newly updated member, if applicable. This is not returned
            if certain fields are passed, such as ``suppress``.
        """
        http = self._state.http
        guild_id = self.guild.id
        me = self._state.self_id == self.id
        payload: Dict[str, Any] = {}
        self_payload: Dict[str, Any] = {}

        if nick is not MISSING:
            nick = nick or ''
            if me:
                self_payload['nick'] = nick
            else:
                payload['nick'] = nick

        if avatar is not MISSING:
            if avatar is None:
                self_payload['avatar'] = None
            else:
                self_payload['avatar'] = utils._bytes_to_base64_data(avatar)

        if banner is not MISSING:
            if banner is None:
                self_payload['banner'] = None
            else:
                self_payload['banner'] = utils._bytes_to_base64_data(banner)

        if bio is not MISSING:
            self_payload['bio'] = bio or ''

        if not me and self_payload:
            raise ValueError("Editing the bio, avatar or banner is only for the bot's own member.")