Search in sources :

Example 1 with ReadyEventListener

use of com.cloudcraftgaming.discal.bot.listeners.ReadyEventListener in project DisCal-Discord-Bot by NovaFox161.

the class Main method main.

public static void main(String[] args) throws IOException {
    // Get bot settings
    Properties p = new Properties();
    p.load(new FileReader(new File("settings.properties")));
    BotSettings.init(p);
    // Init logger
    Logger.getLogger().init();
    // Log in to discord
    client = createClient(BotSettings.TOKEN.get());
    if (client == null)
        throw new NullPointerException("Failed to log in! Client cannot be null!");
    UpdateDisPwData.init();
    Authorization.getAuth().init();
    // Connect to MySQL
    DatabaseManager.getManager().connectToMySQL();
    DatabaseManager.getManager().createTables();
    // Start spark (catch any issues from it so only the site goes down without affecting bot....
    try {
        DiscordAccountHandler.getHandler().init();
        SparkUtils.initSpark();
    } catch (Exception e) {
        Logger.getLogger().exception(null, "'Spark ERROR' by 'PANIC! AT THE WEBSITE'", e, Main.class, true);
    }
    // Register events
    EventDispatcher dispatcher = client.getDispatcher();
    dispatcher.registerListener(new ReadyEventListener());
    // Register modules
    CommandExecutor executor = CommandExecutor.getExecutor().enable();
    executor.registerCommand(new HelpCommand());
    executor.registerCommand(new DisCalCommand());
    executor.registerCommand(new CalendarCommand());
    executor.registerCommand(new AddCalendarCommand());
    executor.registerCommand(new LinkCalendarCommand());
    executor.registerCommand(new TimeCommand());
    executor.registerCommand(new EventListCommand());
    executor.registerCommand(new EventCommand());
    executor.registerCommand(new RsvpCommand());
    executor.registerCommand(new AnnouncementCommand());
    executor.registerCommand(new DevCommand());
    // Load language files.
    MessageManager.loadLangs();
    // Accept commands
    ConsoleCommandExecutor.init();
}
Also used : ReadyEventListener(com.cloudcraftgaming.discal.bot.listeners.ReadyEventListener) ConsoleCommandExecutor(com.cloudcraftgaming.discal.bot.internal.consolecommand.ConsoleCommandExecutor) Properties(java.util.Properties) IOException(java.io.IOException) DiscordException(sx.blah.discord.util.DiscordException) EventDispatcher(sx.blah.discord.api.events.EventDispatcher) FileReader(java.io.FileReader) File(java.io.File)

Aggregations

ConsoleCommandExecutor (com.cloudcraftgaming.discal.bot.internal.consolecommand.ConsoleCommandExecutor)1 ReadyEventListener (com.cloudcraftgaming.discal.bot.listeners.ReadyEventListener)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 EventDispatcher (sx.blah.discord.api.events.EventDispatcher)1 DiscordException (sx.blah.discord.util.DiscordException)1