package com.nincraft.ninbot;

import com.nincraft.ninbot.events.CommandListener;
import lombok.experimental.UtilityClass;
import lombok.extern.log4j.Log4j2;
import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.exceptions.RateLimitedException;

import javax.security.auth.login.LoginException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

@Log4j2
@UtilityClass
public class Ninbot {

    public static void main(String[] args) throws InterruptedException, IOException {
        Properties properties = new Properties();
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream inputStream = loader.getResourceAsStream("ninbot.properties");
        try {
            properties.load(inputStream);
        } catch (IOException e) {
            log.error("Unable to load properties", e);
            throw e;
        }
        JDA jda = null;
        try {
            jda = new JDABuilder(AccountType.BOT).setToken(properties.getProperty("ninbotToken")).buildBlocking();
        } catch (LoginException e) {
            log.error("Failed to login", e);
        } catch (InterruptedException e) {
            log.error("Interrupted", e);
            throw e;
        } catch (RateLimitedException e) {
            log.warn("Rate limit exceeded", e);
        }
        assert jda != null;
        jda.addEventListener(new CommandListener());
    }
}

@@ -367,32 +367,102 @@
 LoginException;%0A
+import java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0A
 import java.io.I
@@ -627,26 +627,17 @@
 throws I
-nterrupted
+O
 Exceptio
@@ -640,17 +640,26 @@
 ption, I
-O
+nterrupted
 Exceptio
@@ -884,53 +884,482 @@
     
-try %7B%0A            properties.load(inputStream
+if (inputStream == null) %7B%0A            log.warn(%22Unable to load properties from classpath, retrying from current directory%22);%0A            try %7B%0A                inputStream = new FileInputStream(%22ninbot.properties%22);%0A            %7D catch (FileNotFoundException e) %7B%0A                log.error(%22Could not find property file%22, e);%0A                throw e;%0A            %7D%0A        %7D%0A        try %7B%0A            properties.load(inputStream);%0A            log.info(%22Property file loaded%22
 );%0A 
@@ -1436,19 +1436,22 @@
  propert
-ies
+y file
 %22, e);%0A 

Fix property file loading