async def set_permissions(self, target, *, overwrite=_undefined, reason=None, **permissions):
http = self._state.http<EOL>if isinstance(target, User):<EOL><INDENT>perm_type = '<STR_LIT>'<EOL><DEDENT>elif isinstance(target, Role):<EOL><INDENT>perm_type = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>raise InvalidArgument('<STR_LIT>')<EOL><DEDENT>if isinstance(overwrite, _Undefined):<EOL><INDENT>if len(permissions) == <NUM_LIT:0>:<EOL><INDENT>raise InvalidArgument('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>overwrite = PermissionOverwrite(**permissions)<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>raise InvalidArgument('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if len(permissions) > <NUM_LIT:0>:<EOL><INDENT>raise InvalidArgument('<STR_LIT>')<EOL><DEDENT><DEDENT>if overwrite is None:<EOL><INDENT>await http.delete_channel_permissions(self.id, target.id, reason=reason)<EOL><DEDENT>elif isinstance(overwrite, PermissionOverwrite):<EOL><INDENT>(allow, deny) = overwrite.pair()<EOL>await http.edit_channel_permissions(self.id, target.id, allow.value, deny.value, perm_type, reason=reason)<EOL><DEDENT>else:<EOL><INDENT>raise InvalidArgument('<STR_LIT>')<EOL><DEDENT>
r"""|coro|

        Sets the channel specific permission overwrites for a target in the
        channel.

        The ``target`` parameter should either be a :class:`Member` or a
        :class:`Role` that belongs to guild.

        The ``overwrite`` parameter, if given, must either be ``None`` or
        :class:`PermissionOverwrite`. For convenience, you can pass in
        keyword arguments denoting :class:`Permissions` attributes. If this is
        done, then you cannot mix the keyword arguments with the ``overwrite``
        parameter.

        If the ``overwrite`` parameter is ``None``, then the permission
        overwrites are deleted.

        You must have the :attr:`~Permissions.manage_roles` permission to use this.

        Examples
        ----------

        Setting allow and deny: ::

            await message.channel.set_permissions(message.author, read_messages=True,
                                                                  send_messages=False)

        Deleting overwrites ::

            await channel.set_permissions(member, overwrite=None)

        Using :class:`PermissionOverwrite` ::

            overwrite = discord.PermissionOverwrite()
            overwrite.send_messages = False
            overwrite.read_messages = True
            await channel.set_permissions(member, overwrite=overwrite)

        Parameters
        -----------
        target
            The :class:`Member` or :class:`Role` to overwrite permissions for.
        overwrite: :class:`PermissionOverwrite`
            The permissions to allow and deny to the target.
        \*\*permissions
            A keyword argument list of permissions to set for ease of use.
            Cannot be mixed with ``overwrite``.
        reason: Optional[:class:`str`]
            The reason for doing this action. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You do not have permissions to edit channel specific permissions.
        HTTPException
            Editing channel specific permissions failed.
        NotFound
            The role or member being edited is not part of the guild.
        InvalidArgument
            The overwrite parameter invalid or the target type was not
            :class:`Role` or :class:`Member`.