protected function execute(\CharlotteDunois\Yasmin\HTTP\APIRequest $item) {
        $endpoint = $this->getRatelimitEndpoint($item);
        $ratelimit = null;
        
        if(!empty($endpoint)) {
            $ratelimit = $this->getRatelimitBucket($endpoint);
            $ratelimit->setBusy(true);
        }
        
        $this->client->emit('debug', 'Executing item "'.$item->getEndpoint().'"');
        
        $item->execute($ratelimit)->then(function ($data) use ($item) {
            if($data === 0) {
                $item->deferred->resolve();
            } elseif($data !== -1) {
                $item->deferred->resolve($data);
            }
        }, function ($error) use ($item) {
            $this->client->emit('debug', 'Request for item "'.$item->getEndpoint().'" failed with '.($error instanceof \Throwable ? 'exception '.\get_class($error) : 'error '.$error));
            $item->deferred->reject($error);
        })->then(null, function ($error) {
            $this->client->handlePromiseRejection($error);
        })->done(function () use ($ratelimit, $endpoint) {
            if($ratelimit instanceof \CharlotteDunois\Yasmin\Interfaces\RatelimitBucketInterface) {
                if(isset($this->bucketRatelimitPromises[$endpoint])) {
                    $this->bucketRatelimitPromises[$endpoint]->done(function () use ($ratelimit) {
                        $ratelimit->setBusy(false);
                        $this->processDelayed();
                    });
                } else {
                    $ratelimit->setBusy(false);
                    $this->processDelayed();
                }
            } else {
                $this->processDelayed();
            }
        });
    }
protected function execute(\CharlotteDunois\Yasmin\HTTP\APIRequest $item) {
        $endpoint = $this->getRatelimitEndpoint($item);
        $ratelimit = null;
        
        if(!empty($endpoint)) {
            $ratelimit = $this->getRatelimitBucket($endpoint);
            $ratelimit->setBusy(true);
        }
        
        $this->client->emit('debug', 'Executing item "'.$item->getEndpoint().'"');
        
        $item->execute($ratelimit)->then(function ($data) use ($item) {
            if($data === 0) {
                $item->deferred->resolve();
            } elseif($data !== -1) {
                $item->deferred->resolve($data);
            }
        }, function ($error) use ($item) {
            $this->client->emit('debug', 'Request for item "'.$item->getEndpoint().'" failed with '.($error instanceof \Throwable ? 'exception '.\get_class($error) : 'error '.$error));
            $item->deferred->reject($error);
        })->then(null, function ($error) {
            $this->client->handlePromiseRejection($error);
        })->done(function () use ($ratelimit, $endpoint) {
            if($ratelimit instanceof \CharlotteDunois\Yasmin\Interfaces\RatelimitBucketInterface) {
                if(isset($this->bucketRatelimitPromises[$endpoint])) {
                    $this->bucketRatelimitPromises[$endpoint]->done(function () use ($ratelimit) {
                        $ratelimit->setBusy(false);
                        $this->processDelayed();
                    });
                } else {
                    $ratelimit->setBusy(false);
                    $this->processDelayed();
                }
            } else {
                $this->processDelayed();
            }
        });
    }
protected function execute ( \ CharlotteDunois \ Yasmin \ HTTP \ APIRequest $ item ) { $ endpoint = $ this -> getRatelimitEndpoint ( $ item ) ; $ ratelimit = null ; if ( ! empty ( $ endpoint ) ) { $ ratelimit = $ this -> getRatelimitBucket ( $ endpoint ) ; $ ratelimit -> setBusy ( true ) ; } $ this -> client -> emit ( 'debug' , 'Executing item "' . $ item -> getEndpoint ( ) . '"' ) ; $ item -> execute ( $ ratelimit ) -> then ( function ( $ data ) use ( $ item ) { if ( $ data === 0 ) { $ item -> deferred -> resolve ( ) ; } elseif ( $ data !== - 1 ) { $ item -> deferred -> resolve ( $ data ) ; } } , function ( $ error ) use ( $ item ) { $ this -> client -> emit ( 'debug' , 'Request for item "' . $ item -> getEndpoint ( ) . '" failed with ' . ( $ error instanceof \ Throwable ? 'exception ' . \ get_class ( $ error ) : 'error ' . $ error ) ) ; $ item -> deferred -> reject ( $ error ) ; } ) -> then ( null , function ( $ error ) { $ this -> client -> handlePromiseRejection ( $ error ) ; } ) -> done ( function ( ) use ( $ ratelimit , $ endpoint ) { if ( $ ratelimit instanceof \ CharlotteDunois \ Yasmin \ Interfaces \ RatelimitBucketInterface ) { if ( isset ( $ this -> bucketRatelimitPromises [ $ endpoint ] ) ) { $ this -> bucketRatelimitPromises [ $ endpoint ] -> done ( function ( ) use ( $ ratelimit ) { $ ratelimit -> setBusy ( false ) ; $ this -> processDelayed ( ) ; } ) ; } else { $ ratelimit -> setBusy ( false ) ; $ this -> processDelayed ( ) ; } } else { $ this -> processDelayed ( ) ; } } ) ; }
Executes an API Request.
@param \CharlotteDunois\Yasmin\HTTP\APIRequest  $item
@return void
Executes an API Request .