use of sx.blah.discord.api.internal.json.responses.GatewayBotResponse in project Discord4J by Discord4J.
the class ClientBuilder method build.
/**
* Creates a {@link IDiscordClient} with the configuration specified by this builder.
*
* @return The new client with the configuration specified by this builder.
*/
public IDiscordClient build() {
if (botToken == null)
throw new DiscordException("No login info present!");
if (withRecommendedShardCount && shard != null)
throw new DiscordException("Cannot use recommend shard count options with a specific shard!");
if (withRecommendedShardCount) {
GatewayBotResponse response = Requests.GENERAL_REQUESTS.GET.makeRequest(DiscordEndpoints.GATEWAY + "/bot", GatewayBotResponse.class, new BasicNameValuePair("Authorization", "Bot " + botToken), new BasicNameValuePair("Content-Type", "application/json"));
shardCount = response.shards;
}
final IDiscordClient client = new DiscordClientImpl(botToken, shard != null ? -1 : shardCount, isDaemon, maxMissedPings, maxReconnectAttempts, retryCount, maxCacheCount, provider, shard, backpressureHandler, minimumPoolSize, maximumPoolSize, overflowCapacity, eventThreadTimeout, eventThreadTimeoutUnit, new PresenceUpdateRequest(status, activity, text, streamUrl));
// Registers events as soon as client is initialized
final EventDispatcher dispatcher = client.getDispatcher();
iListeners.forEach(dispatcher::registerListener);
listeners.forEach(dispatcher::registerListener);
listenerClasses.forEach(dispatcher::registerListener);
return client;
}
Aggregations