File tree Expand file tree Collapse file tree 4 files changed +75
-8
lines changed
src/main/java/com/seailz/jdaframework Expand file tree Collapse file tree 4 files changed +75
-8
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Designed to make developing bots faster and simpler!
1616<dependency >
1717 <groupId >com.github.ice-games</groupId >
1818 <artifactId >java-discord-framework</artifactId >
19- <version >1.2</version >
19+ <version >1.2.2 </version >
2020</dependency >
2121 ```
2222
Original file line number Diff line number Diff line change 5959 <dependency >
6060 <groupId >net.dv8tion</groupId >
6161 <artifactId >JDA</artifactId >
62- <version >5.0.0-alpha.13 </version >
62+ <version >5.0.0-alpha.17 </version >
6363 </dependency >
6464 </dependencies >
6565
Original file line number Diff line number Diff line change 2020public class ModalListener extends ListenerAdapter {
2121
2222 @ Override
23- public void onModalInteraction (@ NotNull ModalInteractionEvent e ){
23+ public void onModalInteraction (@ NotNull ModalInteractionEvent e ) {
24+ Map .Entry <Member , Modal > culprit = null ;
2425 for (Map .Entry <Member , Modal > modalEntry : ModalManager .getModals ()) {
25- if (modalEntry .getValue ().getId ().equals (e .getModalId ()) && modalEntry .getKey ().getId ().equals (e .getMember ().getId ())){
26+ if (modalEntry .getValue ().getId ().equals (e .getModalId ()) && modalEntry .getKey ().getId ().equals (e .getMember ().getId ())) {
2627 ModalMapping [] mappings = e .getValues ().toArray (new ModalMapping [0 ]);
2728 modalEntry .getValue ().getOnSubmit ().accept (e .getMember (), mappings , e );
28- try {
29- ModalManager .getModals ().remove (modalEntry );
30- } catch (ConcurrentModificationException ignored ) {}
29+ culprit = modalEntry ;
30+ break ;
3131 }
3232 }
33- }
3433
34+ if (culprit != null )
35+ ModalManager .getModals ().remove (culprit );
36+ }
3537}
Original file line number Diff line number Diff line change 1+ package com .seailz .jdaframework .utils ;
2+
3+ import java .util .Date ;
4+
5+ /**
6+ * A util for creating timestamps, with ease.
7+ * @author Seailz
8+ */
9+ public class TimestampUtil {
10+
11+ /**
12+ * Generates a Discord timestamp
13+ * @param type The type of timestamp you want to create
14+ * @param time The time it will represent
15+ * @return The generated timestamp
16+ */
17+ public static String createTimestamp (Type type , Date time ) {
18+ if (type == Type .BASE )
19+ return String .valueOf (time .getTime ());
20+ String base = "<t:" + time .getTime () + ":" ;
21+
22+ switch (type ) {
23+ case SHORT_DATE :
24+ base += "d" ;
25+ case LONG_DATE :
26+ base += "D" ;
27+ case SHORT_TIME :
28+ base += "t" ;
29+ case LONG_TIME :
30+ base += "T" ;
31+ case DATE_AND_TIME :
32+ base += "f" ;
33+ case LONG_DATE_AND_TIME :
34+ base += "F" ;
35+ case AGO :
36+ base += "R" ;
37+ }
38+
39+ base += ">" ;
40+ return base ;
41+ }
42+
43+ /**
44+ * Timestamp types
45+ */
46+ public enum Type {
47+ SHORT_DATE ,
48+ // For example: 26/07/2022
49+ LONG_DATE ,
50+ // For example: 26 July 2022
51+ SHORT_TIME ,
52+ // For example 19:50
53+ LONG_TIME ,
54+ // For example: 19:50:43
55+ DATE_AND_TIME ,
56+ // For example: 26 July 2022 19:50
57+ LONG_DATE_AND_TIME ,
58+ // For example: Tuesday, 26 July 2022 19:50
59+ AGO ,
60+ // For example: 10 minutes ago
61+ BASE
62+ // For example: 1658861400
63+ }
64+
65+ }
You can’t perform that action at this time.
0 commit comments