Search in sources :

Example 1 with MiscEvents

use of com.mcmoddev.mmdbot.modules.logging.misc.MiscEvents in project MMDBot by MinecraftModDevelopment.

the class MMDBot method start.

@Override
public void start() {
    instance = this;
    JSONDataMigrator.checkAndMigrate(database);
    if (config.isNewlyGenerated()) {
        MMDBot.LOGGER.warn("A new config file at {} has been generated. Please configure the bot and try again.", config.getConfig().getNioPath());
        System.exit(0);
    } else if (config.getToken().isEmpty()) {
        MMDBot.LOGGER.error("No token is specified in the config. Please configure the bot and try again");
        System.exit(0);
    } else if (config.getOwnerID().isEmpty()) {
        MMDBot.LOGGER.error("No owner ID is specified in the config. Please configure the bot and try again");
        System.exit(0);
    } else if (config.getGuildID() == 0L) {
        MMDBot.LOGGER.error("No guild ID is configured. Please configure the bot and try again.");
        System.exit(0);
    }
    try {
        jda.set(JDABuilder.create(config.getToken(), MMDBot.INTENTS).disableCache(CacheFlag.VOICE_STATE).disableCache(CacheFlag.ACTIVITY).disableCache(CacheFlag.CLIENT_STATUS).disableCache(CacheFlag.ONLINE_STATUS).addEventListeners(new ThreadedEventListener(new MiscEvents(), GENERAL_EVENT_THREAD_POOL)).build().awaitReady());
        CommandModule.setupCommandModule();
        LoggingModule.setupLoggingModule();
        jda.get().getPresence().setActivity(Activity.of(config.getActivityType(), config.getActivityName()));
    } catch (final LoginException exception) {
        MMDBot.LOGGER.error("Error logging in the bot! Please give the bot a valid token in the config file.", exception);
        System.exit(1);
    } catch (InterruptedException e) {
        MMDBot.LOGGER.error("Error awaiting caching.", e);
        System.exit(1);
    }
}
Also used : MiscEvents(com.mcmoddev.mmdbot.modules.logging.misc.MiscEvents) LoginException(javax.security.auth.login.LoginException) ThreadedEventListener(com.mcmoddev.mmdbot.utilities.ThreadedEventListener)

Aggregations

MiscEvents (com.mcmoddev.mmdbot.modules.logging.misc.MiscEvents)1 ThreadedEventListener (com.mcmoddev.mmdbot.utilities.ThreadedEventListener)1 LoginException (javax.security.auth.login.LoginException)1