Skip to content

Commit

Permalink
Fixed ephemeral messages preventing event finalization.
Browse files Browse the repository at this point in the history
  • Loading branch information
ygimenez committed Aug 14, 2023
1 parent 0361521 commit f197e38
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/main/java/com/github/ygimenez/listener/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -213,8 +214,15 @@ public void onGenericSelectMenuInteraction(@NotNull GenericSelectMenuInteraction
);
}

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

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/github/ygimenez/model/ButtonWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public Button getButton() {
return button;
}

/**
* Retrieves the {@link SelectMenu} values currently set for this context.
*
* @return The {@link SelectMenu} values.
*/
public Map<String, List<?>> getDropdownValues() {
return dropdownValues;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/github/ygimenez/model/InteractPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public class InteractPage extends Page {
private final Map<ButtonStyle, ButtonStyle> styles = new EnumMap<>(ButtonStyle.class);
private final Map<Emote, String> caption = new EnumMap<>(Emote.class);

/**
* Create a new {@link InteractPage} for embed-less page, with support for interaction buttons.
* <b>THIS MUST NEVER BE CALLED.</b>
*
* @param content The desired content
*/
protected InteractPage(@NotNull Object content) {
super(content);
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/com/github/ygimenez/model/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
public class Page {
private final Object content;

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

/**
* Create a new {@link Page} for embed-less page, with support for interaction buttons.
* Create a new {@link Page} for embed-less page.
*
* @param content The desired content
* @return A new {@link Page} instance.
Expand All @@ -31,7 +37,7 @@ public static Page of(@NotNull String content) {
}

/**
* Create a new {@link Page} for single-embed page, with support for interaction buttons.
* Create a new {@link Page} for single-embed page.
*
* @param content The desired content
* @return A new {@link Page} instance.
Expand All @@ -41,7 +47,7 @@ public static Page of(@NotNull MessageEmbed content) {
}

/**
* Create a new {@link Page} for multi-embed page, with support for interaction buttons.
* Create a new {@link Page} for multi-embed page.
*
* @param content The desired content
* @return A new {@link Page} instance.
Expand Down

0 comments on commit f197e38

Please sign in to comment.