public function getMessageHistory(array $options)
    {
        $deferred = new Deferred();

        $resolver = new OptionsResolver();
        $resolver->setDefaults(['limit' => 100, 'cache' => true]);
        $resolver->setDefined(['before', 'after', 'around']);
        $resolver->setAllowedTypes('before', [Message::class, 'string']);
        $resolver->setAllowedTypes('after', [Message::class, 'string']);
        $resolver->setAllowedTypes('around', [Message::class, 'string']);
        $resolver->setAllowedValues('limit', range(1, 100));

        $options = $resolver->resolve($options);
        if (isset($options['before'], $options['after']) ||
            isset($options['before'], $options['around']) ||
            isset($options['around'], $options['around'])) {
            $deferred->reject(new \Exception('Can only specify one of before, after and around.'));

            return $deferred->promise();
        }

        $url = "channels/{$this->id}/messages?limit={$options['limit']}";
        if (isset($options['before'])) {
            $url .= '&before='.($options['before'] instanceof Message ? $options['before']->id : $options['before']);
        }
        if (isset($options['after'])) {
            $url .= '&after='.($options['after'] instanceof Message ? $options['after']->id : $options['after']);
        }
        if (isset($options['around'])) {
            $url .= '&around='.($options['around'] instanceof Message ? $options['around']->id : $options['around']);
        }

        $this->http->get($url, null, [], $options['cache'] ? null : 0)->then(
            function ($response) use ($deferred) {
                $messages = new Collection();

                foreach ($response as $message) {
                    $message = $this->factory->create(Message::class, $message, true);
                    $messages->push($message);
                }

                $deferred->resolve($messages);
            },
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
public function getMessageHistory(array $options)
    {
        $deferred = new Deferred();

        $resolver = new OptionsResolver();
        $resolver->setDefaults(['limit' => 100, 'cache' => true]);
        $resolver->setDefined(['before', 'after', 'around']);
        $resolver->setAllowedTypes('before', [Message::class, 'string']);
        $resolver->setAllowedTypes('after', [Message::class, 'string']);
        $resolver->setAllowedTypes('around', [Message::class, 'string']);
        $resolver->setAllowedValues('limit', range(1, 100));

        $options = $resolver->resolve($options);
        if (isset($options['before'], $options['after']) ||
            isset($options['before'], $options['around']) ||
            isset($options['around'], $options['around'])) {
            $deferred->reject(new \Exception('Can only specify one of before, after and around.'));

            return $deferred->promise();
        }

        $url = "channels/{$this->id}/messages?limit={$options['limit']}";
        if (isset($options['before'])) {
            $url .= '&before='.($options['before'] instanceof Message ? $options['before']->id : $options['before']);
        }
        if (isset($options['after'])) {
            $url .= '&after='.($options['after'] instanceof Message ? $options['after']->id : $options['after']);
        }
        if (isset($options['around'])) {
            $url .= '&around='.($options['around'] instanceof Message ? $options['around']->id : $options['around']);
        }

        $this->http->get($url, null, [], $options['cache'] ? null : 0)->then(
            function ($response) use ($deferred) {
                $messages = new Collection();

                foreach ($response as $message) {
                    $message = $this->factory->create(Message::class, $message, true);
                    $messages->push($message);
                }

                $deferred->resolve($messages);
            },
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
public function getMessageHistory ( array $ options ) { $ deferred = new Deferred ( ) ; $ resolver = new OptionsResolver ( ) ; $ resolver -> setDefaults ( [ 'limit' => 100 , 'cache' => true ] ) ; $ resolver -> setDefined ( [ 'before' , 'after' , 'around' ] ) ; $ resolver -> setAllowedTypes ( 'before' , [ Message :: class , 'string' ] ) ; $ resolver -> setAllowedTypes ( 'after' , [ Message :: class , 'string' ] ) ; $ resolver -> setAllowedTypes ( 'around' , [ Message :: class , 'string' ] ) ; $ resolver -> setAllowedValues ( 'limit' , range ( 1 , 100 ) ) ; $ options = $ resolver -> resolve ( $ options ) ; if ( isset ( $ options [ 'before' ] , $ options [ 'after' ] ) || isset ( $ options [ 'before' ] , $ options [ 'around' ] ) || isset ( $ options [ 'around' ] , $ options [ 'around' ] ) ) { $ deferred -> reject ( new \ Exception ( 'Can only specify one of before, after and around.' ) ) ; return $ deferred -> promise ( ) ; } $ url = "channels/{$this->id}/messages?limit={$options['limit']}" ; if ( isset ( $ options [ 'before' ] ) ) { $ url .= '&before=' . ( $ options [ 'before' ] instanceof Message ? $ options [ 'before' ] -> id : $ options [ 'before' ] ) ; } if ( isset ( $ options [ 'after' ] ) ) { $ url .= '&after=' . ( $ options [ 'after' ] instanceof Message ? $ options [ 'after' ] -> id : $ options [ 'after' ] ) ; } if ( isset ( $ options [ 'around' ] ) ) { $ url .= '&around=' . ( $ options [ 'around' ] instanceof Message ? $ options [ 'around' ] -> id : $ options [ 'around' ] ) ; } $ this -> http -> get ( $ url , null , [ ] , $ options [ 'cache' ] ? null : 0 ) -> then ( function ( $ response ) use ( $ deferred ) { $ messages = new Collection ( ) ; foreach ( $ response as $ message ) { $ message = $ this -> factory -> create ( Message :: class , $ message , true ) ; $ messages -> push ( $ message ) ; } $ deferred -> resolve ( $ messages ) ; } , \ React \ Partial \ bind_right ( $ this -> reject , $ deferred ) ) ; return $ deferred -> promise ( ) ; }
Fetches message history.

@param array $options

@return \React\Promise\Promise
Fetches message history .