Search in sources :

Example 1 with MigrationHandler

use of stream.flarebot.flarebot.util.MigrationHandler in project FlareBot by FlareBot.

the class FlareBot method run.

protected void run() {
    if (RUNNING.getAndSet(true))
        return;
    LOGGER.info("Starting run sequence");
    try {
        musicManager = PlayerManager.getPlayerManager(LibraryFactory.getLibrary(new JDAMultiShard(Getters.getShardManager())));
    } catch (UnknownBindingException e) {
        LOGGER.error("Failed to initialize musicManager", e);
    }
    musicManager.getPlayerCreateHooks().register(player -> player.getQueueHookManager().register(new QueueListener()));
    // Any migration
    MigrationHandler migrationHandler = new MigrationHandler();
    LOGGER.info("Loaded " + commandManager.count() + " commands!");
    ApiFactory.bind();
    LOGGER.info("Bound API");
    musicManager.getPlayerCreateHooks().register(player -> player.addEventListener(new PlayerListener(player)));
    analyticsHandler = new AnalyticsHandler();
    analyticsHandler.registerAnalyticSender(new ActivityAnalytics());
    analyticsHandler.registerAnalyticSender(new GuildAnalytics());
    analyticsHandler.registerAnalyticSender(new GuildCountAnalytics());
    LOGGER.info("Registered analytics - Running");
    analyticsHandler.run(isTestBot() ? 1000 : -1);
    GeneralUtils.methodErrorHandler(LOGGER, null, "Executed creations!", "Failed to execute creations!", () -> manager.executeCreations());
    GeneralUtils.methodErrorHandler(LOGGER, null, "Loaded future tasks!", "Failed to load future tasks!", this::loadFutureTasks);
    startTime = System.currentTimeMillis();
    LOGGER.info("FlareBot v" + getVersion() + " booted!");
    GeneralUtils.methodErrorHandler(LOGGER, null, "Sent commands to site!", "Failed to send commands to site!", this::sendCommands);
    GeneralUtils.methodErrorHandler(LOGGER, "Starting tasks!", "Started all tasks, run complete!", "Failed to start all tasks!", this::runTasks);
}
Also used : QueueListener(stream.flarebot.flarebot.music.QueueListener) JDAMultiShard(com.arsenarsen.lavaplayerbridge.utils.JDAMultiShard) GuildCountAnalytics(stream.flarebot.flarebot.analytics.GuildCountAnalytics) GuildAnalytics(stream.flarebot.flarebot.analytics.GuildAnalytics) ActivityAnalytics(stream.flarebot.flarebot.analytics.ActivityAnalytics) MigrationHandler(stream.flarebot.flarebot.util.MigrationHandler) UnknownBindingException(com.arsenarsen.lavaplayerbridge.libraries.UnknownBindingException) PlayerListener(stream.flarebot.flarebot.audio.PlayerListener) AnalyticsHandler(stream.flarebot.flarebot.analytics.AnalyticsHandler)

Aggregations

UnknownBindingException (com.arsenarsen.lavaplayerbridge.libraries.UnknownBindingException)1 JDAMultiShard (com.arsenarsen.lavaplayerbridge.utils.JDAMultiShard)1 ActivityAnalytics (stream.flarebot.flarebot.analytics.ActivityAnalytics)1 AnalyticsHandler (stream.flarebot.flarebot.analytics.AnalyticsHandler)1 GuildAnalytics (stream.flarebot.flarebot.analytics.GuildAnalytics)1 GuildCountAnalytics (stream.flarebot.flarebot.analytics.GuildCountAnalytics)1 PlayerListener (stream.flarebot.flarebot.audio.PlayerListener)1 QueueListener (stream.flarebot.flarebot.music.QueueListener)1 MigrationHandler (stream.flarebot.flarebot.util.MigrationHandler)1