diff --git a/.gitignore b/.gitignore index a1c2a23..0bcd8da 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +.gradle/* +build/* +.idea/* diff --git a/.gradle/6.7/executionHistory/executionHistory.bin b/.gradle/6.7/executionHistory/executionHistory.bin index 5a54d5b..0b91f0d 100644 Binary files a/.gradle/6.7/executionHistory/executionHistory.bin and b/.gradle/6.7/executionHistory/executionHistory.bin differ diff --git a/.gradle/6.7/executionHistory/executionHistory.lock b/.gradle/6.7/executionHistory/executionHistory.lock index d434f0e..bb20e96 100644 Binary files a/.gradle/6.7/executionHistory/executionHistory.lock and b/.gradle/6.7/executionHistory/executionHistory.lock differ diff --git a/.gradle/6.7/fileHashes/fileHashes.bin b/.gradle/6.7/fileHashes/fileHashes.bin index 6930990..1eee8b8 100644 Binary files a/.gradle/6.7/fileHashes/fileHashes.bin and b/.gradle/6.7/fileHashes/fileHashes.bin differ diff --git a/.gradle/6.7/fileHashes/fileHashes.lock b/.gradle/6.7/fileHashes/fileHashes.lock index 6aaa6bc..90764d2 100644 Binary files a/.gradle/6.7/fileHashes/fileHashes.lock and b/.gradle/6.7/fileHashes/fileHashes.lock differ diff --git a/.gradle/6.7/javaCompile/classAnalysis.bin b/.gradle/6.7/javaCompile/classAnalysis.bin index ac45de2..5cf5d49 100644 Binary files a/.gradle/6.7/javaCompile/classAnalysis.bin and b/.gradle/6.7/javaCompile/classAnalysis.bin differ diff --git a/.gradle/6.7/javaCompile/javaCompile.lock b/.gradle/6.7/javaCompile/javaCompile.lock index 7a8a458..188e1d9 100644 Binary files a/.gradle/6.7/javaCompile/javaCompile.lock and b/.gradle/6.7/javaCompile/javaCompile.lock differ diff --git a/.gradle/6.7/javaCompile/taskHistory.bin b/.gradle/6.7/javaCompile/taskHistory.bin index 7e9f545..d29ac82 100644 Binary files a/.gradle/6.7/javaCompile/taskHistory.bin and b/.gradle/6.7/javaCompile/taskHistory.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 63087b2..0bf73d7 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index f9ccc7c..4911962 100644 --- a/build.gradle +++ b/build.gradle @@ -11,10 +11,10 @@ repositories { } dependencies { + implementation 'org.jetbrains:annotations:20.1.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' compile 'com.discord4j:discord4j-core:3.1.3' - compile 'org.slf4j:slf4j-api:1.7.25' } shadowJar { diff --git a/src/main/java/io/github/paldiu/obsidian/Obsidian.java b/src/main/java/io/github/paldiu/obsidian/Obsidian.java index 064ce98..bcb3fd5 100644 --- a/src/main/java/io/github/paldiu/obsidian/Obsidian.java +++ b/src/main/java/io/github/paldiu/obsidian/Obsidian.java @@ -1,11 +1,16 @@ package io.github.paldiu.obsidian; -import io.github.paldiu.obsidian.utils.Constants; +import io.github.paldiu.obsidian.utils.Bot; public final class Obsidian { - // This class only initializes the bot. - // Using utility classes to manage instances. + private static Bot bot; + public static void main(String[] args) { - Constants.getRegistry().verify(); + bot = new Bot(); + getBot().verify(); + } + + public static Bot getBot() { + return bot; } } diff --git a/src/main/java/io/github/paldiu/obsidian/commands/Commands.java b/src/main/java/io/github/paldiu/obsidian/commands/Commands.java index ae0f25d..18b00db 100644 --- a/src/main/java/io/github/paldiu/obsidian/commands/Commands.java +++ b/src/main/java/io/github/paldiu/obsidian/commands/Commands.java @@ -10,12 +10,4 @@ public class Commands { }; } - - private Command coloredRank(User user, Message message) { - return () -> { - message.getGuild(). - }; - } - - } diff --git a/src/main/java/io/github/paldiu/obsidian/embed/Embedder.java b/src/main/java/io/github/paldiu/obsidian/embed/Embedder.java new file mode 100644 index 0000000..cdf5370 --- /dev/null +++ b/src/main/java/io/github/paldiu/obsidian/embed/Embedder.java @@ -0,0 +1,4 @@ +package io.github.paldiu.obsidian.embed; + +public class Embedder { +} diff --git a/src/main/java/io/github/paldiu/obsidian/listener/EventListener.java b/src/main/java/io/github/paldiu/obsidian/listener/EventListener.java new file mode 100644 index 0000000..0c3b9fc --- /dev/null +++ b/src/main/java/io/github/paldiu/obsidian/listener/EventListener.java @@ -0,0 +1,19 @@ +package io.github.paldiu.obsidian.listener; + +import discord4j.core.event.domain.Event; +import reactor.core.publisher.Mono; + +import java.util.logging.Logger; + +public interface EventListener { + Logger LOG = Logger.getLogger(EventListener.class.getSimpleName()); + + Class getEventType(); + + Mono execute(T event); + + default Mono handleError(Throwable error) { + LOG.severe("Unable to process " + getEventType().getSimpleName() + "\n" + error.getMessage()); + return Mono.empty(); + } +} diff --git a/src/main/java/io/github/paldiu/obsidian/props/PropertiesManager.java b/src/main/java/io/github/paldiu/obsidian/props/PropertiesManager.java index cfff8ca..0cdee64 100644 --- a/src/main/java/io/github/paldiu/obsidian/props/PropertiesManager.java +++ b/src/main/java/io/github/paldiu/obsidian/props/PropertiesManager.java @@ -27,7 +27,7 @@ public class PropertiesManager { properties.setProperty("author", "Predicate#0001"); properties.setProperty("version", "1.0.0"); properties.setProperty("encoding", "UTF_8"); - properties.setProperty("token", "REPLACEME"); + properties.setProperty("token", "BOT_TOKEN"); return this; } @@ -47,7 +47,7 @@ public class PropertiesManager { try (OutputStream stream = new FileOutputStream(child)) { properties.store(stream, null); } catch (IOException e) { - Constants.getLogger().error(e.getMessage()); + Constants.getLogger().severe(e.getMessage()); } } diff --git a/src/main/java/io/github/paldiu/obsidian/ticketer/Ticket.java b/src/main/java/io/github/paldiu/obsidian/ticketer/Ticket.java new file mode 100644 index 0000000..4993c97 --- /dev/null +++ b/src/main/java/io/github/paldiu/obsidian/ticketer/Ticket.java @@ -0,0 +1,17 @@ +package io.github.paldiu.obsidian.ticketer; + +import discord4j.core.object.entity.User; + +import java.util.function.Supplier; + +public interface Ticket { + User getUserCreated(); + + User getAssignedUser(); + + Supplier getCommissionSpecifications(); + + Supplier getCommissionPrice(); + + TicketStatus getTicketStatus(); +} diff --git a/src/main/java/io/github/paldiu/obsidian/ticketer/TicketModule.java b/src/main/java/io/github/paldiu/obsidian/ticketer/TicketModule.java new file mode 100644 index 0000000..b1c9756 --- /dev/null +++ b/src/main/java/io/github/paldiu/obsidian/ticketer/TicketModule.java @@ -0,0 +1,51 @@ +package io.github.paldiu.obsidian.ticketer; + +import discord4j.core.object.entity.User; + +import java.util.function.Supplier; + +public class TicketModule { + private volatile Ticket ticket; + + public TicketModule(Ticket ticket) { + this.ticket = ticket; + } + + public TicketModule() { + ticket = null; + } + + public TicketModule createNewTicket(User userCreated, User assigned, Supplier commissionSpecifications, Supplier commissionPrice, TicketStatus type) { + ticket = new Ticket() { + @Override + public User getUserCreated() { + return assigned; + } + + @Override + public User getAssignedUser() { + return userCreated; + } + + @Override + public Supplier getCommissionSpecifications() { + return commissionSpecifications; + } + + @Override + public Supplier getCommissionPrice() { + return commissionPrice; + } + + @Override + public TicketStatus getTicketStatus() { + return type; + } + }; + return this; + } + + public Ticket getTicket() { + return ticket; + } +} diff --git a/src/main/java/io/github/paldiu/obsidian/ticketer/TicketStatus.java b/src/main/java/io/github/paldiu/obsidian/ticketer/TicketStatus.java new file mode 100644 index 0000000..816ec40 --- /dev/null +++ b/src/main/java/io/github/paldiu/obsidian/ticketer/TicketStatus.java @@ -0,0 +1,19 @@ +package io.github.paldiu.obsidian.ticketer; + +public enum TicketStatus { + OPEN("The ticket has been marked as open."), + PENDING("The ticket is now pending approval."), + IN_PROGRESS("The ticket is now in progress."), + COMPLETED("The ticket has been marked as completed."), + CLOSED("The ticket has been marked as closed."); + + private final String message; + + TicketStatus(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } +} diff --git a/src/main/java/io/github/paldiu/obsidian/utils/Registry.java b/src/main/java/io/github/paldiu/obsidian/utils/Bot.java similarity index 94% rename from src/main/java/io/github/paldiu/obsidian/utils/Registry.java rename to src/main/java/io/github/paldiu/obsidian/utils/Bot.java index 2bd9b99..09fa79a 100644 --- a/src/main/java/io/github/paldiu/obsidian/utils/Registry.java +++ b/src/main/java/io/github/paldiu/obsidian/utils/Bot.java @@ -2,7 +2,6 @@ package io.github.paldiu.obsidian.utils; import discord4j.common.util.Snowflake; import discord4j.core.DiscordClient; -import discord4j.core.DiscordClientBuilder; import discord4j.core.GatewayDiscordClient; import discord4j.core.event.domain.lifecycle.ReadyEvent; import discord4j.core.object.entity.User; @@ -11,12 +10,12 @@ import discord4j.discordjson.json.UserData; import discord4j.rest.response.ResponseFunction; import io.github.paldiu.obsidian.props.PropertiesManager; -public final class Registry { +public final class Bot { private final GatewayDiscordClient gateway; private final DiscordClient client; private final String token; - public Registry() { + public Bot() { PropertiesManager.getInstance().load(); token = PropertiesManager.getInstance().getToken(); client = DiscordClient.builder(token) diff --git a/src/main/java/io/github/paldiu/obsidian/utils/Constants.java b/src/main/java/io/github/paldiu/obsidian/utils/Constants.java index 131692a..cd0bb77 100644 --- a/src/main/java/io/github/paldiu/obsidian/utils/Constants.java +++ b/src/main/java/io/github/paldiu/obsidian/utils/Constants.java @@ -1,17 +1,19 @@ package io.github.paldiu.obsidian.utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.function.Consumer; +import java.util.logging.Logger; +// Utility Class public final class Constants { - private static final Logger logger = LoggerFactory.getLogger("obsidian"); - private static final Registry registry = new Registry(); + private static final Logger logger = Logger.getLogger("obsidian"); public static Logger getLogger() { return logger; } - public static Registry getRegistry() { - return registry; + public static void forEach(T[] array, Consumer action) { + for (T obj : array) { + action.accept(obj); + } } }