Search in sources :

Example 1 with ShardWatcher

use of net.kodehawa.mantarobot.core.shard.watcher.ShardWatcher in project MantaroBot by Mantaro.

the class ShardedMantaro method startPostLoadProcedure.

private void startPostLoadProcedure(long start) {
    long end = System.currentTimeMillis();
    MantaroBot bot = MantaroBot.getInstance();
    // Start the reconnect queue.
    bot.getCore().markAsReady();
    System.out.println("[-=-=-=-=-=- MANTARO STARTED -=-=-=-=-=-]");
    LogUtils.shard(String.format("Loaded all %d shards in %d seconds.", totalShards, (end - start) / 1000));
    log.info("Loaded all shards successfully... Starting ShardWatcher! Status: {}", MantaroCore.getLoadState());
    Async.thread("ShardWatcherThread", new ShardWatcher());
    bot.getCore().getShardEventBus().post(new PostLoadEvent());
    startUpdaters();
    bot.startCheckingBirthdays();
    Async.task(() -> {
        try {
            SnowflakeCacheView<VoiceChannel> vc = MantaroBot.getInstance().getVoiceChannelCache();
            MantaroBot.getInstance().getStatsClient().gauge("music_players", vc.stream().filter(voiceChannel -> voiceChannel.getMembers().contains(voiceChannel.getGuild().getSelfMember())).count());
        }// Avoid the scheduled task to unexpectedly end on exception (probably ConcurrentModificationException but let's just catch all errors)
         catch (Exception ignored) {
        }
    }, 20, TimeUnit.SECONDS);
}
Also used : PostLoadEvent(net.kodehawa.mantarobot.core.listeners.events.PostLoadEvent) ShardWatcher(net.kodehawa.mantarobot.core.shard.watcher.ShardWatcher) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel) MantaroBot(net.kodehawa.mantarobot.MantaroBot) PostingException(com.github.natanbc.discordbotsapi.PostingException)

Aggregations

PostingException (com.github.natanbc.discordbotsapi.PostingException)1 VoiceChannel (net.dv8tion.jda.core.entities.VoiceChannel)1 MantaroBot (net.kodehawa.mantarobot.MantaroBot)1 PostLoadEvent (net.kodehawa.mantarobot.core.listeners.events.PostLoadEvent)1 ShardWatcher (net.kodehawa.mantarobot.core.shard.watcher.ShardWatcher)1