105 lines
2.7 KiB
Java
105 lines
2.7 KiB
Java
|
package moe.kayla.Shikinami;
|
||
|
|
||
|
import net.dv8tion.jda.api.JDA;
|
||
|
import net.dv8tion.jda.api.JDABuilder;
|
||
|
import org.simpleyaml.configuration.file.YamlConfiguration;
|
||
|
import org.simpleyaml.exceptions.InvalidConfigurationException;
|
||
|
import org.slf4j.Logger;
|
||
|
import org.slf4j.LoggerFactory;
|
||
|
|
||
|
import java.io.File;
|
||
|
import java.io.FileNotFoundException;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
public class Shikinami {
|
||
|
|
||
|
private File CONFIG_FILE = new File("config.yml");
|
||
|
|
||
|
public YamlConfiguration yamlConfiguration;
|
||
|
|
||
|
public Logger logger = LoggerFactory.getLogger("Shikinami");
|
||
|
|
||
|
public static String PREFIX;
|
||
|
|
||
|
public static Shikinami instance;
|
||
|
|
||
|
public ShikinamiConfig config;
|
||
|
|
||
|
public JDA discordInstance;
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
try {
|
||
|
Shikinami shiki = new Shikinami();
|
||
|
shiki.start();
|
||
|
} catch (Exception ex) {
|
||
|
System.out.println("Failed to start Shikinami Instance, check your Java installation.");
|
||
|
ex.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void start() {
|
||
|
instance = this;
|
||
|
|
||
|
logger.info("Starting Shikinami.");
|
||
|
System.out.println("If no other messages are present, logger failed to instantiate.");
|
||
|
|
||
|
logger.info("Config load start...");
|
||
|
|
||
|
if (!CONFIG_FILE.exists()) {
|
||
|
try {
|
||
|
CONFIG_FILE.createNewFile();
|
||
|
} catch (IOException ex) {
|
||
|
logger.warn("Failed to create the configuration file. Stopping. (Try creating configuration directory.)");
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
yamlConfiguration.load(CONFIG_FILE);
|
||
|
} catch (FileNotFoundException e) {
|
||
|
e.printStackTrace();
|
||
|
logger.warn("File not found, attempting to create.");
|
||
|
|
||
|
} catch (IOException | InvalidConfigurationException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
|
||
|
config = new ShikinamiConfig(yamlConfiguration);
|
||
|
if(config.load()) {
|
||
|
logger.info("Config loaded, proceeding.");
|
||
|
} else {
|
||
|
logger.error("Failed to load configuration. Stopping process.");
|
||
|
Runtime.getRuntime().exit(0);
|
||
|
}
|
||
|
logger.info("Registering shutdown hook.");
|
||
|
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
|
||
|
|
||
|
PREFIX = config.getPrefix();
|
||
|
|
||
|
//Makes our JDA instance.
|
||
|
startDiscord();
|
||
|
}
|
||
|
|
||
|
public void stop() {
|
||
|
JDA jda = JDABuilder.create().
|
||
|
}
|
||
|
|
||
|
public void startDiscord() {
|
||
|
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
Static logger info reference.
|
||
|
*/
|
||
|
public static void info(String str) {
|
||
|
instance.logger.info(str);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
Static Logger Error reference.
|
||
|
*/
|
||
|
public static void error(String str) {
|
||
|
instance.logger.error(str);
|
||
|
}
|
||
|
}
|