Skip to content

Commit f197e38

Browse files
committed
Fixed ephemeral messages preventing event finalization.
1 parent 0361521 commit f197e38

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

src/main/java/com/github/ygimenez/listener/EventHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
1717
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
1818
import net.dv8tion.jda.api.hooks.ListenerAdapter;
19+
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
1920
import org.jetbrains.annotations.NotNull;
2021
import org.jetbrains.annotations.Nullable;
2122

@@ -213,8 +214,15 @@ public void onGenericSelectMenuInteraction(@NotNull GenericSelectMenuInteraction
213214
);
214215
}
215216

217+
/**
218+
* Retrieves the {@link SelectMenu} values for the supplied event ID.
219+
*
220+
* @param eventId The event ID.
221+
* @return The {@link Map} containing the values for this event, or null if the event doesn't exist.
222+
*/
216223
public Map<String, List<?>> getDropdownValues(String eventId) {
217-
return dropdownValues.get(eventId);
224+
if (!events.containsKey(eventId)) return null;
225+
return dropdownValues.computeIfAbsent(eventId, k -> new HashMap<>());
218226
}
219227

220228
/**

src/main/java/com/github/ygimenez/model/ButtonWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public Button getButton() {
8080
return button;
8181
}
8282

83+
/**
84+
* Retrieves the {@link SelectMenu} values currently set for this context.
85+
*
86+
* @return The {@link SelectMenu} values.
87+
*/
8388
public Map<String, List<?>> getDropdownValues() {
8489
return dropdownValues;
8590
}

src/main/java/com/github/ygimenez/model/InteractPage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public class InteractPage extends Page {
2020
private final Map<ButtonStyle, ButtonStyle> styles = new EnumMap<>(ButtonStyle.class);
2121
private final Map<Emote, String> caption = new EnumMap<>(Emote.class);
2222

23+
/**
24+
* Create a new {@link InteractPage} for embed-less page, with support for interaction buttons.
25+
* <b>THIS MUST NEVER BE CALLED.</b>
26+
*
27+
* @param content The desired content
28+
*/
2329
protected InteractPage(@NotNull Object content) {
2430
super(content);
2531
}

src/main/java/com/github/ygimenez/model/Page.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
public class Page {
1313
private final Object content;
1414

15+
/**
16+
* Create a new {@link Page} for embed-less page.
17+
* <b>THIS MUST NEVER BE CALLED.</b>
18+
*
19+
* @param content The desired content
20+
*/
1521
protected Page(@NotNull Object content) throws IllegalArgumentException {
1622
if (!(content instanceof String || content instanceof MessageEmbed || content instanceof EmbedCluster)) {
1723
throw new IllegalArgumentException("Page content must be either a String or a MessageEmbed");
@@ -21,7 +27,7 @@ protected Page(@NotNull Object content) throws IllegalArgumentException {
2127
}
2228

2329
/**
24-
* Create a new {@link Page} for embed-less page, with support for interaction buttons.
30+
* Create a new {@link Page} for embed-less page.
2531
*
2632
* @param content The desired content
2733
* @return A new {@link Page} instance.
@@ -31,7 +37,7 @@ public static Page of(@NotNull String content) {
3137
}
3238

3339
/**
34-
* Create a new {@link Page} for single-embed page, with support for interaction buttons.
40+
* Create a new {@link Page} for single-embed page.
3541
*
3642
* @param content The desired content
3743
* @return A new {@link Page} instance.
@@ -41,7 +47,7 @@ public static Page of(@NotNull MessageEmbed content) {
4147
}
4248

4349
/**
44-
* Create a new {@link Page} for multi-embed page, with support for interaction buttons.
50+
* Create a new {@link Page} for multi-embed page.
4551
*
4652
* @param content The desired content
4753
* @return A new {@link Page} instance.

0 commit comments

Comments
 (0)