use of stream.flarebot.flarebot.mod.nino.NINOListener in project FlareBot by FlareBot.
the class FlareBot method init.
public void init() throws InterruptedException {
LOGGER.info("Starting init!");
manager = new FlareBotManager();
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
Metrics.setup();
RestAction.DEFAULT_FAILURE = t -> {
if (t instanceof ErrorResponseException) {
ErrorResponseException e = (ErrorResponseException) t;
Metrics.failedRestActions.labels(String.valueOf(e.getErrorCode())).inc();
if (// Socket timeout
e.getErrorCode() == -1)
return;
}
LOGGER.warn("Failed RestAction", t);
};
events = new Events(this);
LOGGER.info("Starting builders");
try {
shardManager = new DefaultShardManagerBuilder().addEventListeners(events).addEventListeners(new ModlogEvents()).addEventListeners(Metrics.instance().jdaEventMetricsListener).addEventListeners(new NINOListener()).setToken(config.getString("bot.token").get()).setAudioSendFactory(new NativeAudioSendFactory()).setWebsocketFactory(new WebSocketFactory(new WebSocketListener())).setShardsTotal(-1).setHttpClientBuilder(client.newBuilder()).setBulkDeleteSplittingEnabled(false).build();
commandManager = new CommandManager();
} catch (Exception e) {
LOGGER.error("Could not log in!", e);
Thread.sleep(500);
System.exit(1);
return;
}
System.setErr(new PrintStream(new OutputStream() {
// Nothing really so all good.
@Override
public void write(int b) {
}
}));
// No operation STDERR. Will not do much of anything, except to filter out some Jsoup spam
manager = new FlareBotManager();
manager.executeCreations();
}
Aggregations