use of de.btobastian.javacord.entities.impl.ImplInvite in project Javacord by BtoBastian.
the class ImplDiscordAPI method parseInvite.
@Override
public Future<Invite> parseInvite(final String invite, FutureCallback<Invite> callback) {
final String inviteCode = invite.replace("https://discord.gg/", "").replace("http://discord.gg/", "");
ListenableFuture<Invite> future = getThreadPool().getListeningExecutorService().submit(new Callable<Invite>() {
@Override
public Invite call() throws Exception {
logger.debug("Trying to parse invite {} (parsed code: {})", invite, inviteCode);
HttpResponse<JsonNode> response = Unirest.get("https://discordapp.com/api/v6/invite/" + inviteCode).header("authorization", token).asJson();
checkResponse(response);
logger.debug("Parsed invite {} (parsed code: {})", invite, inviteCode);
return new ImplInvite(ImplDiscordAPI.this, response.getBody().getObject());
}
});
if (callback != null) {
Futures.addCallback(future, callback);
}
return future;
}
Aggregations