diff --git a/src/main/java/com/seailz/jdaframework/modals/listeners/ModalListener.java b/src/main/java/com/seailz/jdaframework/modals/listeners/ModalListener.java index d6c2598..dd15cb3 100644 --- a/src/main/java/com/seailz/jdaframework/modals/listeners/ModalListener.java +++ b/src/main/java/com/seailz/jdaframework/modals/listeners/ModalListener.java @@ -20,16 +20,18 @@ public class ModalListener extends ListenerAdapter { @Override - public void onModalInteraction(@NotNull ModalInteractionEvent e){ + public void onModalInteraction(@NotNull ModalInteractionEvent e) { + Map.Entry culprit = null; for (Map.Entry modalEntry : ModalManager.getModals()) { - if (modalEntry.getValue().getId().equals(e.getModalId()) && modalEntry.getKey().getId().equals(e.getMember().getId())){ + if (modalEntry.getValue().getId().equals(e.getModalId()) && modalEntry.getKey().getId().equals(e.getMember().getId())) { ModalMapping[] mappings = e.getValues().toArray(new ModalMapping[0]); modalEntry.getValue().getOnSubmit().accept(e.getMember(), mappings, e); - try { - ModalManager.getModals().remove(modalEntry); - } catch (ConcurrentModificationException ignored) {} + culprit = modalEntry; + break; } } - } + if (culprit != null) + ModalManager.getModals().remove(culprit); + } } diff --git a/src/main/java/com/seailz/jdaframework/utils/TimestampUtil.java b/src/main/java/com/seailz/jdaframework/utils/TimestampUtil.java new file mode 100644 index 0000000..d7d925b --- /dev/null +++ b/src/main/java/com/seailz/jdaframework/utils/TimestampUtil.java @@ -0,0 +1,65 @@ +package com.seailz.jdaframework.utils; + +import java.util.Date; + +/** + * A util for creating timestamps, with ease. + * @author Seailz + */ +public class TimestampUtil { + + /** + * Generates a Discord timestamp + * @param type The type of timestamp you want to create + * @param time The time it will represent + * @return The generated timestamp + */ + public static String createTimestamp(Type type, Date time) { + if (type == Type.BASE) + return String.valueOf(time.getTime()); + String base = "