Skip to content

Commit

Permalink
Fixed the Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
beanbeanjuice committed Jul 2, 2024
1 parent d0a48fd commit dbb077f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.beanbeanjuice.cafebot.CafeBot;
import com.beanbeanjuice.cafebot.utility.commands.Command;
import com.beanbeanjuice.cafebot.utility.commands.ICommand;
import com.beanbeanjuice.cafebot.utility.sections.interactions.CafeInteraction;
import com.beanbeanjuice.cafebot.utility.sections.interactions.ICommandInteraction;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ private void handleCategory(final StringSelectInteractionEvent event) {
boolean isHome = value.equalsIgnoreCase("all");
MessageEmbed menuEmbed = isHome ? menuHandler.getAllMenuEmbed() : menuHandler.getCategoryMenuEmbed(CafeCategory.valueOf(value));

// TODO: Sometimes replaces after adding the components.
event.editMessageEmbeds(menuEmbed).setReplace(true).queue((hook) -> {
List<ActionRow> rows = new ArrayList<>();
rows.add(ActionRow.of(menuHandler.getAllStringSelectMenu()));
if (!isHome) rows.add(ActionRow.of(menuHandler.getItemStringSelectMenu(CafeCategory.valueOf(value))));
hook.editOriginalComponents(rows).delay(1, TimeUnit.SECONDS).queue((ignored) -> { }, (e) -> { // TODO: Check this.
cafeBot.getLogger().log(MenuListener.class, LogLevel.ERROR, "Error Adding Components: " + e, e);
});
});
List<ActionRow> rows = new ArrayList<>();
rows.add(ActionRow.of(menuHandler.getAllStringSelectMenu()));
if (!isHome) rows.add(ActionRow.of(menuHandler.getItemStringSelectMenu(CafeCategory.valueOf(value))));

event.editMessageEmbeds(menuEmbed)
.setComponents(rows)
.setReplace(true).queue();
}

private void handleItem(final StringSelectInteractionEvent event) {
Expand All @@ -66,14 +64,13 @@ private void handleItem(final StringSelectInteractionEvent event) {

MenuHandler menuHandler = cafeBot.getMenuHandler();

event.editMessageEmbeds(menuHandler.getItemEmbed(itemString, cafeUser)).setReplace(true).queue((hook) -> {
List<ActionRow> rows = new ArrayList<>();
rows.add(ActionRow.of(menuHandler.getAllStringSelectMenu()));
rows.add(ActionRow.of(menuHandler.getItemEntitySelectMenu(itemString)));
hook.editOriginalComponents(rows).delay(1, TimeUnit.SECONDS).queue((ignored) -> { }, (e) -> { // TODO: Check this.
cafeBot.getLogger().log(MenuListener.class, LogLevel.ERROR, "Error Adding Components: " + e, e);
});
});
List<ActionRow> rows = new ArrayList<>();
rows.add(ActionRow.of(menuHandler.getAllStringSelectMenu()));
rows.add(ActionRow.of(menuHandler.getItemEntitySelectMenu(itemString)));

event.editMessageEmbeds(menuHandler.getItemEmbed(itemString, cafeUser))
.setComponents(rows)
.setReplace(true).queue();
});
}

Expand Down

0 comments on commit dbb077f

Please sign in to comment.