public function setPermissions(Part $part, ChannelPermission $permissions = null)
    {
        $deferred = new Deferred();

        if ($part instanceof Member) {
            $type = 'member';
        } elseif ($part instanceof Role) {
            $type = 'role';
        } else {
            return false;
        }

        if (is_null($permissions)) {
            $permissions = $this->factory->create(ChannelPermission::class);
        }

        list($allow, $deny) = $permissions->bitwise;

        $payload = [
            'id'    => $part->id,
            'type'  => $type,
            'allow' => $allow,
            'deny'  => $deny,
        ];

        if (! $this->created) {
            $this->attributes['permission_overwrites'][] = $payload;
            $deferred->resolve();
        } else {
            $this->http->put("channels/{$this->id}/permissions/{$part->id}", $payload)->then(
                \React\Partial\bind_right($this->resolve, $deferred),
                \React\Partial\bind_right($this->reject, $deferred)
            );
        }

        return $deferred->promise();
    }
public function setPermissions(Part $part, ChannelPermission $permissions = null)
    {
        $deferred = new Deferred();

        if ($part instanceof Member) {
            $type = 'member';
        } elseif ($part instanceof Role) {
            $type = 'role';
        } else {
            return false;
        }

        if (is_null($permissions)) {
            $permissions = $this->factory->create(ChannelPermission::class);
        }

        list($allow, $deny) = $permissions->bitwise;

        $payload = [
            'id'    => $part->id,
            'type'  => $type,
            'allow' => $allow,
            'deny'  => $deny,
        ];

        if (! $this->created) {
            $this->attributes['permission_overwrites'][] = $payload;
            $deferred->resolve();
        } else {
            $this->http->put("channels/{$this->id}/permissions/{$part->id}", $payload)->then(
                \React\Partial\bind_right($this->resolve, $deferred),
                \React\Partial\bind_right($this->reject, $deferred)
            );
        }

        return $deferred->promise();
    }
public function setPermissions ( Part $ part , ChannelPermission $ permissions = null ) { $ deferred = new Deferred ( ) ; if ( $ part instanceof Member ) { $ type = 'member' ; } elseif ( $ part instanceof Role ) { $ type = 'role' ; } else { return false ; } if ( is_null ( $ permissions ) ) { $ permissions = $ this -> factory -> create ( ChannelPermission :: class ) ; } list ( $ allow , $ deny ) = $ permissions -> bitwise ; $ payload = [ 'id' => $ part -> id , 'type' => $ type , 'allow' => $ allow , 'deny' => $ deny , ] ; if ( ! $ this -> created ) { $ this -> attributes [ 'permission_overwrites' ] [ ] = $ payload ; $ deferred -> resolve ( ) ; } else { $ this -> http -> put ( "channels/{$this->id}/permissions/{$part->id}" , $ payload ) -> then ( \ React \ Partial \ bind_right ( $ this -> resolve , $ deferred ) , \ React \ Partial \ bind_right ( $ this -> reject , $ deferred ) ) ; } return $ deferred -> promise ( ) ; }
Sets a permission value to the channel.

@param Member|Role       $part        Either a Member or Role, permissions will be set on it.
@param ChannelPermission $permissions The permissions that define what the Member/Role can and cannot do.

@return \React\Promise\Promise
Sets a permission value to the channel .