commit 75d15470f374fb8b90724c863b2a5b488f5cbfd3 Author: unknown Date: Wed Mar 23 13:31:23 2022 -0700 Initialization, python moved to python branch diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..8ceae32 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..d8e9561 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..492c28c --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e2ef482 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/configuration/config.yml b/configuration/config.yml new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..8699882 --- /dev/null +++ b/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + moe.kayla + Shikinami + DEV-1 + + + 8 + 8 + + + + + + + net.dv8tion + JDA + 4.2.0_247 + + + me.carleslc.Simple-YAML + Simple-Yaml + 1.7.2 + + + org.slf4j + slf4j-simple + 1.7.9 + + + org.mongodb + mongodb-driver-sync + 4.0.6 + + + com.sedmelluq + lavaplayer + 1.3.53 + + + + + + jcenter + https://jcenter.bintray.com/ + + + central + bintray + https://jcenter.bintray.com + + + jitpack.io + https://jitpack.io + + + + \ No newline at end of file diff --git a/src/main/java/moe/kayla/Shikinami/Shikinami.java b/src/main/java/moe/kayla/Shikinami/Shikinami.java new file mode 100644 index 0000000..24b0e1b --- /dev/null +++ b/src/main/java/moe/kayla/Shikinami/Shikinami.java @@ -0,0 +1,104 @@ +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); + } +} diff --git a/src/main/java/moe/kayla/Shikinami/ShikinamiConfig.java b/src/main/java/moe/kayla/Shikinami/ShikinamiConfig.java new file mode 100644 index 0000000..966b526 --- /dev/null +++ b/src/main/java/moe/kayla/Shikinami/ShikinamiConfig.java @@ -0,0 +1,71 @@ +package moe.kayla.Shikinami; + +import org.simpleyaml.configuration.ConfigurationSection; +import org.simpleyaml.configuration.file.YamlConfiguration; + +import static moe.kayla.Shikinami.Shikinami.error; +import static moe.kayla.Shikinami.Shikinami.info; + +public class ShikinamiConfig { + + public YamlConfiguration configuration; + + /* + Discord Variable Section + */ + private String token; + private String logChannel; + private String ownerId; + private String mainGuild; + private String clientId; + private String prefix; + private int defaultInvitePermissionLevel; + + /* + Shiki Variable Section + */ + private boolean sharded; + + public ShikinamiConfig(YamlConfiguration configuration) { + //Load config on class creation... + this.configuration = configuration; + } + + public boolean load() { + try { + //Discord loaders + info("Starting Discord Configuration load"); + ConfigurationSection discord = configuration.getConfigurationSection("discord"); + token = discord.getString("token"); + info("!!! DO NOT SHARE !!! Token - " + token); + logChannel = discord.getString("logChannel"); + info("Logging Channel - " + logChannel); + ownerId = discord.getString("ownerId"); + info("Owner ID - " + ownerId); + mainGuild = discord.getString("mainGuild"); + info("Main Guild - " + mainGuild); + clientId = discord.getString("clientId"); + defaultInvitePermissionLevel = discord.getInt("invitePermissionLevel"); + info("Invite link - " + assembleDefaultInvite()); + prefix = discord.getString("prefix"); + info("Prefix - " + prefix); + //Shiki loaders + ConfigurationSection main = configuration.getConfigurationSection("main"); + sharded = main.getBoolean("sharded"); + } catch(Exception ex) { + ex.printStackTrace(); + error("Failed to load configuration!"); + return false; + } + info("Configuration Loaded"); + return true; + } + + public String assembleDefaultInvite() { + return "https://discord.com/oauth2/authorize?client_id=" + clientId + "&scope=bot&permissions=" + defaultInvitePermissionLevel; + } + + public String getPrefix() { + return prefix; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..2bced09 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,30 @@ +#███████╗██╗ ██╗██╗██╗ ██╗██╗███╗ ██╗ █████╗ ███╗ ███╗██╗ +#██╔════╝██║ ██║██║██║ ██╔╝██║████╗ ██║██╔══██╗████╗ ████║██║ +#███████╗███████║██║█████╔╝ ██║██╔██╗ ██║███████║██╔████╔██║██║ +#╚════██║██╔══██║██║██╔═██╗ ██║██║╚██╗██║██╔══██║██║╚██╔╝██║██║ +#███████║██║ ██║██║██║ ██╗██║██║ ╚████║██║ ██║██║ ╚═╝ ██║██║ +#╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ +#-------------------------------------------------------------- +# SHIKINAMI Default Configuration File (With Comments) +# All Rights Reserved, LaikaFI +#-------------------------------------------------------------- +#DISCORD CONFIG STACK +discord: + #Paste in your bot token, if you don't know what this is you shouldn't be making a bot. + token: "DO NOT SHARE THIS" + #The main guild the bot will recognize and do protection actions on. (Use LossPrevention for more in-depth actions!) + mainGuild: "" + #The channel ID the bot will send important logging messages to. + logChannel: "" + #The user ID of the owner of the bot. + ownerId: "" + #The client ID of the bot (for invite generation) + clientId: "" + #Level of permissions for the invite (If you don't know this, use https://discordapi.com/permissions.html) (ADMINISTRATOR is default) + invitePermissionLevel: 8 + #Prefix before bot commands (default is +) + prefix: "+" +#SHIKINAMI MAIN CONFIG STACK +main: + #Currently, unimplemented, maybe in the future if performance becomes and issue. + sharded: false \ No newline at end of file diff --git a/target/classes/config.yml b/target/classes/config.yml new file mode 100644 index 0000000..e69de29 diff --git a/target/classes/moe/kayla/Shikinami/Shikinami.class b/target/classes/moe/kayla/Shikinami/Shikinami.class new file mode 100644 index 0000000..73f855f Binary files /dev/null and b/target/classes/moe/kayla/Shikinami/Shikinami.class differ