From 99d55f36da84d561a97eb76a3163b355300ef46e Mon Sep 17 00:00:00 2001 From: Paldiu Date: Mon, 1 Mar 2021 08:56:06 -0600 Subject: [PATCH] Send it! --- .gitignore | 3 ++ .../6.7/executionHistory/executionHistory.bin | Bin 37374 -> 58717 bytes .../executionHistory/executionHistory.lock | Bin 17 -> 17 bytes .gradle/6.7/fileHashes/fileHashes.bin | Bin 19097 -> 19897 bytes .gradle/6.7/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .gradle/6.7/javaCompile/classAnalysis.bin | Bin 2418784 -> 2422822 bytes .gradle/6.7/javaCompile/javaCompile.lock | Bin 17 -> 17 bytes .gradle/6.7/javaCompile/taskHistory.bin | Bin 24466 -> 30603 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .idea/vcs.xml | 6 +++ build.gradle | 2 +- .../io/github/paldiu/obsidian/Obsidian.java | 13 +++-- .../paldiu/obsidian/commands/Commands.java | 8 --- .../paldiu/obsidian/embed/Embedder.java | 4 ++ .../obsidian/listener/EventListener.java | 19 +++++++ .../obsidian/props/PropertiesManager.java | 4 +- .../paldiu/obsidian/ticketer/Ticket.java | 17 ++++++ .../obsidian/ticketer/TicketModule.java | 51 ++++++++++++++++++ .../obsidian/ticketer/TicketStatus.java | 19 +++++++ .../utils/{Registry.java => Bot.java} | 5 +- .../paldiu/obsidian/utils/Constants.java | 14 ++--- 21 files changed, 141 insertions(+), 24 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 src/main/java/io/github/paldiu/obsidian/embed/Embedder.java create mode 100644 src/main/java/io/github/paldiu/obsidian/listener/EventListener.java create mode 100644 src/main/java/io/github/paldiu/obsidian/ticketer/Ticket.java create mode 100644 src/main/java/io/github/paldiu/obsidian/ticketer/TicketModule.java create mode 100644 src/main/java/io/github/paldiu/obsidian/ticketer/TicketStatus.java rename src/main/java/io/github/paldiu/obsidian/utils/{Registry.java => Bot.java} (94%) 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 5a54d5bf78f881c326d6100cac8c785bb0751a57..0b91f0de3dc55b905de02b0fe0f4077bcc8400a0 100644 GIT binary patch delta 1993 zcmeyjnCb2*<_RK#j0|Alx0`{%*%`=G+^G0Pe6pm37SqIkn_VS#RvH*HFa(DIu^$6N z5YO!7g2c4SjI?62w4{oX)a?9Hv%-utW7C|xQiwrplP4ScyKXk{uVZ1nHkmQlZ1RL? zminyJlBA-<%)H{5#Js%xlEjkCd?4G%K+jOmAjT*yImIx|*vQBvez}}kB-i@i9svVd3llPbkU1qw)ZMV1y>AA&aM1DQ{zC(C$qRDH7~UY=3*HC4ag#W7%#@PEH$sh2dWlo+XMA`9}1^1 zoaBFaCFbC=v@eX?K(*&(J!9=sOnVPo8T>&wc`j?F@hLVnB} zpZKVHc|Ec;o1((%9K^UCWZ2~T78z*JmSiSprO5{uKH&T*WCm&iS_?_7&n6ql!R%3 z8VJ{L4P@Npw=L?7_rWZ_HZ~cj{1T|^X1f2HH#_y|w3vB~{vIj*X^bm@hAD8u6oA8M zGEmE8`93Z&NUA%vTRM{G^db=^vGqFsf*+Ry!^U88Qk#W33!kw4vzGSv<>xGa=B2BA zXP%mpT3nKu2hQX!nMJ9|CHX~_qMHx4u`n|}o?O@+jg;)ce0Z||2$ID}t$N8hiN(dt z0uxfrIWP162zPQc-&kecoWclJ4o|JH#0^pY31pNuEG5I_ieYB0`Mfv6y2dcHYOng0 zZQU6uj9~Q=IMhR24NItu5MOY@_}@WR8NhgGNgwL=6fUO?3vVX7Maq>m9aQc9%?Q>c zi%-)_kg=2Jb@2%?3p{UiJ5if+AdWl6M)gM5>|dK5yH+s@?w#%QKIN}M+XtWR>!&I0 zf6q9%pt}+p#ISS$b1aPi0c5Hsj0a2pP*?UHWbiu~_g=2W$wg>@@h zO*&PsNbV?G%m~&agGbL7kfFM03cxu9>hIg)7a4`i7+f1Z9u3&svOa+ktV0-!j>-8w zrx;&>V+NQ#WI-7QYQ~bTG)=i9hD(>9-q>;M*V|tRRa|gY;NXPjD}E7Xfom6*FnvpK zvKJCqcJ*{`z~|J;(&s;8_0`1;t5+t)p7~Jldvi&D2NP3}e!DljO6;rz0KjGo5dZ)H diff --git a/.gradle/6.7/executionHistory/executionHistory.lock b/.gradle/6.7/executionHistory/executionHistory.lock index d434f0e665b6dcec2445ab365ae34ca803bbd477..bb20e9612c761b0873e0b05a24a5b205a0a7ac50 100644 GIT binary patch literal 17 UcmZS9V-XJCK7Yzr1_)3C049|Kp#T5? literal 17 UcmZS9V-XJCK7Yzr1_)pW048<=f&c&j diff --git a/.gradle/6.7/fileHashes/fileHashes.bin b/.gradle/6.7/fileHashes/fileHashes.bin index 6930990afa0e783413de9ad65042c6aa997ba629..1eee8b8f5a79a844146176523c7a529d41f5d77a 100644 GIT binary patch literal 19897 zcmeI4`BM{D9Kbi>DghMK3Q8*##0!fD1{5$3hc+Pukl`qri9tYR3Z+zt6%kO%A%|9i zB4vU_Kq~_xD8krswIG2EN-QEp@j$ExFvy@%5VV`Ted9FSzo7HonIt=(C;$bZ02F`%Pyh=2 zUkdn>6Jeprn5|-}c4qGA(Eydp-q)TcpF5LX+bHsW2m}ea8 zvfEiwJcPLC4$P$t?H)$Wx4MXXUyAveq-^uY@lIDMK7n~F!>~-@ z;j{&Do)hM6vicvzS6FWm7g%8~Uzk{3cK0`X#624^SFmfOfw`mo6wk)IH^PuP6q{*- zxW^3UeK9f1H*6P1BF?>o`6Hdz#&QAI9C7|?%%4OR26vxOZbh7@#QcTmtIli9Qa$SZ z_h3Hxtb`wUz;Be|3e1^0Oq=oZP34FS{4qE1Vamc2dS6nn*TUTBbneEU(9s~oJy&3E z9LAFc+VwOc&O3v-Dc45Aw%8@0-iM93g#z4uBQ8k8+=?rIbH!u*WyJZdn6Kni zqmb}=jx0pIE{9w$ZPv<+P zHOmfBuXn*5KN1A93Oxt+Pyh-*0Vn_kpa2wr0#E=7KmjNK1)u;FfC5ke3P1rU00p1` z6o3Ly017|>C;$bZ02F`%Pyh-*0Vn_kpa2wr0#E=7KmjOVMWk?M;g>Ti;UVzTpyOcp-z3(~XAybvli!&#|JC8lP8-$6_g?1{w2H>Bc}?fgii& z;n18cT}FN1s|zY)STsTX(x2f%H@vi}20g7kJO(z}=PuE4^Hm#Rt9WP(mI>YH_{BWP zP;qu1bAIJ2Z5 zJWbguKNQgy)$r>RW5d-|!g$NaQbi-0$G*GBFnB>X zBnz0?QZK7_r8|ZLevi6YrXC}t{SGn+)ye~nR(|4p2`!4O&XLz&2jt9aIH5A+L0vZ} z;{e@=D?aJm@XW_x)@^Z43@Z=KLo|_s3ta z^YCBCJjyYBF6ZE+kkv1?H>-S?r8f9yN2pIVi#|sF7gL1=VNXs83lDp9L%nxX^9VtP zo)O*nAWU0oci;+&F0k+F$9F6xauGd1T?K3@N&Q~X;0xcX(?S2OowqXP-r z7wJYQ%k@&xpCMa=7D8M-pMQIfHH#iEwArRNn@>DQ-5sH>L4Muv%M H-IeV>cQnz4 delta 334 zcmdlvn{nn;#tkMCj69P~B@8AXm5`WhD=9HKSJGheSs?uvNS8_(Ox`P{#KdU0QSpcP zMuQh(lN~*-)!+Sg;(Gg;Ox4|n<`I1h|E*zQU@YHJA0)>B28^~qO3xTbXacb!2n%pO zx>tK$>f_%f-!Wf^$6uagGXS%u=f6feU34*992DtzTm{NcQnz>i5%u24h9l!X^`vyk- vcLM5A9VK85418Eza?eq1(cPyVsrNtf&9(F|eFfD~1=Im@3A6L$WG^!S^>16Q diff --git a/.gradle/6.7/fileHashes/fileHashes.lock b/.gradle/6.7/fileHashes/fileHashes.lock index 6aaa6bc15a3f17c2566b7cc7451d69ce8596f3f4..90764d2c0c456a453070c9c483dc959cf77eb8cd 100644 GIT binary patch literal 17 UcmZQ>O?b5ViBD!10|fX206N?R?f?J) literal 17 UcmZQ>O?b5ViBD!10|W>F06L!pu>b%7 diff --git a/.gradle/6.7/javaCompile/classAnalysis.bin b/.gradle/6.7/javaCompile/classAnalysis.bin index ac45de29c839a4cbcf01f0465a71286be0c5b83f..5cf5d4923897083dbcaa43c1f6d19f43ae9dcb0c 100644 GIT binary patch delta 3488 zcmd6pdrVVT9LIZZUr>6vfFQJ`$OTkD*7%$-3WdRr#qEQqE) zqJkxy=rBr@MP(|5#WN=}b7p@yvrLAGE-X$q;_%HB=8XQab9y_5XtDe;vzvUH+ne9> zdw%zvd;O9VeA@2>turG)L;I|VpBScM{WV?c$u<$W;`$2OrSUVy1GXkN&5@f1P;MHv zvkk09zw}d&6-;7J@#lTZIl=b!S@gpb>cMy_1~|Gy#25+c4v|i125+M$NV-?T6xu2+ zi#Hkt^Zq2XqeB|22A#0+du^|y<%$#|!^kmy7=MfcwOk3vaDZLt&WB2lWqvC=XsvjC zt`Op0GMZnd^cORIgWF?WyKV|k2Y!U}Ym{ApYlu|mqy3weVkg*un!@P|3Z^;l%c{1- zE>8tV5EnxyjAL#cr1@WYt?;yO09DVTKam0#{JKb!inh<8`%^(VtgN83106GuTud?v zhIh`RGZpmt7{EeRnrb5IXrzq`KmnT6OZ&^24zr>C>bg3?bT9`^x=p_m%dJQr=8vwS zryEr@YVg>_MkrBhv#N^&ThL~?nx&aSD+0WV+Z(!GcTepw>}47=@XDiN>&)7*snLd+C9F22Mr9tRWmS znso-Fb(L+Uu9Pb>L>Zo@+o7Gst>z3*bM&4?vIQB9_=-M9` znpsP#*o0Y6X!Gt=YB87cx+VBmZ?PKn{36c88T1wrEDeqeV|~k(>>%05bZ;ZP)G5ns z;;o#?%EP~sL3E<;%{#dz5px@GGSG;rC-^KJu1w?y>m-tJXV4}&Y;KoEXVsZ41|45g zJae@!$85lDk6kF(lLNF3D}fSLrHlPQv$Je(m@{K111q=tMZye9E=lyV{=&KrX@Se5 zAa|OIgY`L*Am?ri?ObA!y#bntwi%dYLW}p6EHtlO%bALJU6ybI%W4#%#iDlX)DJ@tqHc@?F4PmFp}#2*-PhTR-xCP#!=WG=Fm=;NjdVc_qzAgJNKILto0 zjnTUpTe+>iHD|{<38e{ziT-@1KOdt!69kM!6q%q3%-kvtg{|2jUUS#E4zlz4c_SCEl;0gje03e3G55I@Fen}=tUPn3c;vABBBNoNnMO!7o``yF*| z@+;%=8g$=}s5kIYS+-VS3?GNcsvAo&67}O!54kJBb#9!a7jWV*srN#jUn-D6{8Au` zF)ejtNf8ot)>dIhi+vZ}I~#uFZB{!J>?zlOiQ1bH%qaegyzp CLPoFv delta 33 ncmeBv&p2s6;{*{_1|SgKX!t^WqJzX_NeL|`568`}629&Ltd0qD diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 63087b2793d8e5b731aa810f861151501f3b2f5a..0bf73d72be8a1a98f7a4ebc6a46def3d4110b0c6 100644 GIT binary patch literal 17 TcmZSfFf`{V@R_c_00EW&8qfl0 literal 17 TcmZSfFf`{V@R_c_00A-p8nXgR 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); + } } }