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

Code before:
            else:
                payload['color'] = colour.value

        if name is not MISSING:
            payload['name'] = name

        if permissions is not MISSING:
            payload['permissions'] = permissions.value

        if hoist is not MISSING:
            payload['hoist'] = hoist

        if display_icon is not MISSING:
            payload['icon'] = None
            payload['unicode_emoji'] = None
            if isinstance(display_icon, bytes):
                payload['icon'] = _bytes_to_base64_data(display_icon)
            else:
                payload['unicode_emoji'] = display_icon

        if mentionable is not MISSING:
            payload['mentionable'] = mentionable

        colours = {
            'primary_color': payload['color'],
        }

        actual_secondary_colour = secondary_colour or secondary_color
        actual_tertiary_colour = tertiary_colour or tertiary_color

        if actual_secondary_colour is not MISSING:
            if actual_secondary_colour is None:
                colours['secondary_color'] = None
            elif isinstance(actual_secondary_colour, int):
                colours['secondary_color'] = actual_secondary_colour
            else:
                colours['secondary_color'] = actual_secondary_colour.value
        if actual_tertiary_colour is not MISSING:
            if actual_tertiary_colour is None:
                colours['tertiary_color'] = None
            elif isinstance(actual_tertiary_colour, int):
                colours['tertiary_color'] = actual_tertiary_colour
            else:
                colours['tertiary_color'] = actual_tertiary_colour.value

        payload['colors'] = colours
        data = await self._state.http.edit_role(self.guild.id, self.id, reason=reason, **payload)
        return Role(guild=self.guild, data=data, state=self._state)

    @overload
    async def move(self, *, beginning: bool, offset: int = ..., reason: Optional[str] = ...):

Review comment (suggestion):
Maybe we should change this to not pass the ``color`` key on the payload at all, because it is not recommended anymore, use the ``colors`` field everytime, even if not using a gradient/holographic colour.

Code after:
        Returns
        --------
        :class:`Role`
            The newly edited role.
        """
        if position is not MISSING:
            await self._move(position, reason=reason)

        payload: Dict[str, Any] = {}

        colours: Dict[str, Any] = {}

        if color is not MISSING:
            colour = color

        if colour is not MISSING:
            if isinstance(colour, int):
                colours['primary_color'] = colour
            else:
                colours['primary_color'] = colour.value

        if name is not MISSING:
            payload['name'] = name

        if permissions is not MISSING:
            payload['permissions'] = permissions.value

        if hoist is not MISSING:
            payload['hoist'] = hoist

        if display_icon is not MISSING:
            payload['icon'] = None
            payload['unicode_emoji'] = None
            if isinstance(display_icon, bytes):
                payload['icon'] = _bytes_to_base64_data(display_icon)
            else:
                payload['unicode_emoji'] = display_icon

        if mentionable is not MISSING:
            payload['mentionable'] = mentionable

        actual_secondary_colour = secondary_colour or secondary_color
        actual_tertiary_colour = tertiary_colour or tertiary_color

        if actual_secondary_colour is not MISSING:
            if actual_secondary_colour is None:
                colours['secondary_color'] = None
            elif isinstance(actual_secondary_colour, int):
                colours['secondary_color'] = actual_secondary_colour
            else:
                colours['secondary_color'] = actual_secondary_colour.value