public CompletableFuture < T > execute ( Function < RestRequestResult , T > function ) { api . getRatelimitManager ( ) . queueRequest ( this ) ; CompletableFuture < T > future = new CompletableFuture <> ( ) ; result . whenComplete ( ( result , throwable ) -> { if ( throwable != null ) { future . completeExceptionally ( throwable ) ; return ; } try { future . complete ( function . apply ( result ) ) ; } catch ( Throwable t ) { future . completeExceptionally ( t ) ; } } ) ; return future ; }
Executes the request . This will automatically retry if we hit a ratelimit .