Search in sources :

Example 1 with VoiceRegionJSON

use of io.discloader.discloader.network.json.VoiceRegionJSON in project DiscLoader by R3alCl0ud.

the class Guild method getVoiceRegions.

@Override
public CompletableFuture<List<VoiceRegion>> getVoiceRegions() {
    CompletableFuture<List<VoiceRegion>> future = new CompletableFuture<List<VoiceRegion>>();
    CompletableFuture<VoiceRegionJSON[]> cf = getLoader().rest.request(Methods.GET, Endpoints.guildRegions(getID()), new RESTOptions(), VoiceRegionJSON[].class);
    cf.thenAcceptAsync(regions -> {
        List<VoiceRegion> rgs = new ArrayList<>();
        for (VoiceRegionJSON region : regions) {
            rgs.add(new VoiceRegion(region));
        }
        future.complete(rgs);
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) VoiceRegion(io.discloader.discloader.entity.guild.VoiceRegion) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) VoiceRegionJSON(io.discloader.discloader.network.json.VoiceRegionJSON)

Aggregations

VoiceRegion (io.discloader.discloader.entity.guild.VoiceRegion)1 VoiceRegionJSON (io.discloader.discloader.network.json.VoiceRegionJSON)1 RESTOptions (io.discloader.discloader.network.rest.RESTOptions)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1