public function deleteMessages($messages)
    {
        $deferred = new Deferred();

        if (! is_array($messages) &&
            ! ($messages instanceof Traversable)
        ) {
            $deferred->reject(new \Exception('$messages must be an array or implement Traversable.'));

            return $deferred->promise();
        }

        $count = count($messages);

        if ($count == 0) {
            $deferred->reject(new \Exception('You cannot delete 0 messages.'));

            return $deferred->promise();
        } elseif ($count == 1) {
            $deferred->reject(new \Exception('You cannot delete 1 message.'));

            return $deferred->promise();
        }

        $messageID = [];

        foreach ($messages as $message) {
            if ($message instanceof Message) {
                $messageID[] = $message->id;
            } else {
                $messageID[] = $message;
            }
        }

        $this->http->post(
            "channels/{$this->id}/messages/bulk_delete",
            [
                'messages' => $messageID,
            ]
        )->then(
            \React\Partial\bind_right($this->resolve, $deferred),
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
public function deleteMessages($messages)
    {
        $deferred = new Deferred();

        if (! is_array($messages) &&
            ! ($messages instanceof Traversable)
        ) {
            $deferred->reject(new \Exception('$messages must be an array or implement Traversable.'));

            return $deferred->promise();
        }

        $count = count($messages);

        if ($count == 0) {
            $deferred->reject(new \Exception('You cannot delete 0 messages.'));

            return $deferred->promise();
        } elseif ($count == 1) {
            $deferred->reject(new \Exception('You cannot delete 1 message.'));

            return $deferred->promise();
        }

        $messageID = [];

        foreach ($messages as $message) {
            if ($message instanceof Message) {
                $messageID[] = $message->id;
            } else {
                $messageID[] = $message;
            }
        }

        $this->http->post(
            "channels/{$this->id}/messages/bulk_delete",
            [
                'messages' => $messageID,
            ]
        )->then(
            \React\Partial\bind_right($this->resolve, $deferred),
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
public function deleteMessages ( $ messages ) { $ deferred = new Deferred ( ) ; if ( ! is_array ( $ messages ) && ! ( $ messages instanceof Traversable ) ) { $ deferred -> reject ( new \ Exception ( '$messages must be an array or implement Traversable.' ) ) ; return $ deferred -> promise ( ) ; } $ count = count ( $ messages ) ; if ( $ count == 0 ) { $ deferred -> reject ( new \ Exception ( 'You cannot delete 0 messages.' ) ) ; return $ deferred -> promise ( ) ; } elseif ( $ count == 1 ) { $ deferred -> reject ( new \ Exception ( 'You cannot delete 1 message.' ) ) ; return $ deferred -> promise ( ) ; } $ messageID = [ ] ; foreach ( $ messages as $ message ) { if ( $ message instanceof Message ) { $ messageID [ ] = $ message -> id ; } else { $ messageID [ ] = $ message ; } } $ this -> http -> post ( "channels/{$this->id}/messages/bulk_delete" , [ 'messages' => $ messageID , ] ) -> then ( \ React \ Partial \ bind_right ( $ this -> resolve , $ deferred ) , \ React \ Partial \ bind_right ( $ this -> reject , $ deferred ) ) ; return $ deferred -> promise ( ) ; }
Bulk deletes an array of messages.

@param array|Traversable $messages An array of messages to delete.

@return \React\Promise\Promise
Bulk deletes an array of messages .