diff --git a/build.gradle.kts b/build.gradle.kts index 2f8c5cc..3fb31dc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,6 +10,8 @@ repositories { } dependencies { + implementation("net.dv8tion:JDA:5.3.0") + testImplementation(platform("org.junit:junit-bom:5.10.0")) testImplementation("org.junit.jupiter:junit-jupiter") } diff --git a/src/main/java/com/windurango/BotProperties.java b/src/main/java/com/windurango/BotProperties.java new file mode 100644 index 0000000..a8786d2 --- /dev/null +++ b/src/main/java/com/windurango/BotProperties.java @@ -0,0 +1,101 @@ +package com.windurango; + +public class BotProperties { + private static String BOT_NAME; + private static String BOT_VERSION; + private static String BOT_AUTHOR; + + private static String BOT_TOKEN; + private static String BOT_SECRET; + + private static String BOT_PREFIX; + + private static String[] BOT_INTENTS; + private static String[] BOT_LOADABLE_MODULES; + private static String[] BOT_MESSAGE_LISTENERS; + + private BotProperties() { + + } + + public BotProperties getInstance() { + return new BotProperties(); + } + + public static String getBotName() { + return BOT_NAME; + } + + public static void setBotName(String botName) { + BOT_NAME = botName; + } + + public static String getBotVersion() { + return BOT_VERSION; + } + + public static void setBotVersion(String botVersion) { + BOT_VERSION = botVersion; + } + + public static String getBotAuthor() { + return BOT_AUTHOR; + } + + public static void setBotAuthor(String botAuthor) { + BOT_AUTHOR = botAuthor; + } + + public static String getBotToken() { + return BOT_TOKEN; + } + + public static void setBotToken(String botToken) { + BOT_TOKEN = botToken; + } + + public static String getBotSecret() { + return BOT_SECRET; + } + + public static void setBotSecret(String botSecret) { + BOT_SECRET = botSecret; + } + + public static String getBotPrefix() { + return BOT_PREFIX; + } + + public static void setBotPrefix(String botPrefix) { + BOT_PREFIX = botPrefix; + } + + public static String[] getBotIntents() { + return BOT_INTENTS; + } + + public static void setBotIntents(String[] botIntents) { + BOT_INTENTS = botIntents; + } + + public static String[] getBotLoadableModules() { + return BOT_LOADABLE_MODULES; + } + + public static void setBotLoadableModules(String[] botLoadableModules) { + BOT_LOADABLE_MODULES = botLoadableModules; + } + + public static String[] getBotMessageListeners() { + return BOT_MESSAGE_LISTENERS; + } + + public static void setBotMessageListeners(String[] botMessageListeners) { + BOT_MESSAGE_LISTENERS = botMessageListeners; + } + + // TODO: Load properties from a configuration file. + public static void loadProperties() { + + } +} diff --git a/src/main/java/com/windurango/Main.java b/src/main/java/com/windurango/Main.java index b80126c..f8503a2 100644 --- a/src/main/java/com/windurango/Main.java +++ b/src/main/java/com/windurango/Main.java @@ -1,7 +1,26 @@ package com.windurango; +import net.dv8tion.jda.api.JDABuilder; +import net.dv8tion.jda.api.requests.GatewayIntent; + +import java.util.Collection; +import java.util.EnumSet; + public class Main { + private static final Collection intents = EnumSet.of(GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MESSAGE_REACTIONS); + + // TODO: Load these properties from a configuration file + public static final String PREFIX = "!"; + public static final String BOT_NAME = "Windurango"; + public static final String BOT_TOKEN = ""; + public static final String BOT_VERSION = "0.0.1"; + public static final String BOT_AUTHOR = "Windurango Team"; + public static final String + public static void main(String[] args) { - System.out.println("Hello, World!"); + JDABuilder + .create(BOT_TOKEN, intents) + .addEventListeners(new MessageListener()) + .build(); } } \ No newline at end of file diff --git a/src/main/java/com/windurango/logging/LogLevel.java b/src/main/java/com/windurango/logging/LogLevel.java new file mode 100644 index 0000000..db461cc --- /dev/null +++ b/src/main/java/com/windurango/logging/LogLevel.java @@ -0,0 +1,11 @@ +package com.windurango.logging; + +public enum LogLevel { + INFO, + DEBUG, + WARNING, + ERROR, + CRITICAL, + ALL, + NONE +} diff --git a/src/main/java/com/windurango/logging/LogMessage.java b/src/main/java/com/windurango/logging/LogMessage.java new file mode 100644 index 0000000..5cf3fcc --- /dev/null +++ b/src/main/java/com/windurango/logging/LogMessage.java @@ -0,0 +1,51 @@ +package com.windurango.logging; + +public class LogMessage { + private String message; + private LogLevel logLevel; + private String timestamp; + private Class source; + + public LogMessage() { + + } + + public LogMessage(String message, LogLevel logLevel, String timestamp, Class source) { + this.message = message; + this.logLevel = logLevel; + this.timestamp = timestamp; + this.source = source; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public LogLevel getLogLevel() { + return logLevel; + } + + public void setLogLevel(LogLevel logLevel) { + this.logLevel = logLevel; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public Class getSource() { + return source; + } + + public void setSource(Class source) { + this.source = source; + } +} diff --git a/src/main/java/com/windurango/logging/Logger.java b/src/main/java/com/windurango/logging/Logger.java new file mode 100644 index 0000000..25050dd --- /dev/null +++ b/src/main/java/com/windurango/logging/Logger.java @@ -0,0 +1,62 @@ +package com.windurango.logging; + +import java.util.ArrayList; +import java.util.List; + +/** + * A simple generics based singleton logger class. + */ +public class Logger { + private static Logger instance; + + private static LogLevel logLevel; + + List logs = new ArrayList<>(); + + private Logger() { + logLevel = LogLevel.INFO; + } + + @SuppressWarnings({"unchecked"}) + public static synchronized Logger getInstance() { + if (instance == null) instance = new Logger<>(); + + return (Logger) instance; + } + + public void logInfo(String message) { + LogMessage logMessage = new LogMessage(); + + logMessage.setLogLevel(logLevel); + logMessage.setMessage(message); + logMessage.setTimestamp(String.valueOf(System.currentTimeMillis())); + + // TODO: Get the class of this Logger object based on generics. + + logs.add(logMessage); + } + + public void logWarning() { + + } + + public void logError() { + + } + + public void logCritical() { + + } + + public void logDebug() { + + } + + public static LogLevel getLogLevel() { + return logLevel; + } + + public static void setLogLevel(LogLevel logLevel) { + Logger.logLevel = logLevel; + } +} \ No newline at end of file