Skip to content

Commit 1688b69

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 6c14c56 + 1c3905f commit 1688b69

File tree

4 files changed

+75
-8
lines changed

4 files changed

+75
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
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

src/main/java/com/seailz/jdaframework/modals/listeners/ModalListener.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@
2020
public 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
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
}

0 commit comments

Comments
 (0)