2022-10-21 00:59:00 +00:00
|
|
|
package com.alttd.selectMenuManager;
|
|
|
|
|
|
|
|
|
|
import com.alttd.selectMenuManager.selectMenus.SelectMenuAuction;
|
2024-01-13 07:27:42 +00:00
|
|
|
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
2022-10-21 00:59:00 +00:00
|
|
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
public class SelectMenuManager extends ListenerAdapter {
|
|
|
|
|
|
|
|
|
|
private final List<DiscordSelectMenu> buttons;
|
|
|
|
|
|
|
|
|
|
public SelectMenuManager() {
|
2022-10-30 01:05:16 +00:00
|
|
|
buttons = List.of(new SelectMenuAuction(this));
|
2022-10-21 00:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-01-14 12:26:43 +00:00
|
|
|
public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent event) {
|
2025-11-08 18:35:28 +00:00
|
|
|
String selectMenuId = event.getSelectMenu().getCustomId();
|
2022-10-21 00:59:00 +00:00
|
|
|
Optional<DiscordSelectMenu> first = buttons.stream()
|
|
|
|
|
.filter(discordModal -> discordModal.getSelectMenuId().equalsIgnoreCase(selectMenuId))
|
|
|
|
|
.findFirst();
|
|
|
|
|
if (first.isEmpty()) {
|
2023-01-08 02:48:45 +00:00
|
|
|
// event.replyEmbeds(new EmbedBuilder()
|
|
|
|
|
// .setTitle("Invalid command")
|
|
|
|
|
// .setDescription("Unable to process select menu with id: [" + selectMenuId + "], please report this issue to a Teri")
|
|
|
|
|
// .setColor(Color.RED)
|
|
|
|
|
// .build())
|
|
|
|
|
// .setEphemeral(true)
|
|
|
|
|
// .queue(RestAction.getDefaultSuccess(), Util::handleFailure);
|
2022-10-21 00:59:00 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2024-01-14 12:26:43 +00:00
|
|
|
first.get().execute(event);
|
2022-10-21 00:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public @Nullable DiscordSelectMenu getDiscordSelectMenuFor(String buttonId) {
|
|
|
|
|
Optional<DiscordSelectMenu> first = buttons.stream()
|
|
|
|
|
.filter(discordSelectMenu -> discordSelectMenu.getSelectMenuId().equalsIgnoreCase(buttonId))
|
|
|
|
|
.findFirst();
|
2024-01-13 07:27:42 +00:00
|
|
|
return first.orElse(null);
|
2022-10-21 00:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|