use of com.freya02.botcommands.api.pagination.interactive.InteractiveMenu in project BotCommands by freya022.
the class SlashInteractiveMenu method interactiveMenu.
@JDASlashCommand(name = "interactive")
public void interactiveMenu(GuildSlashEvent event) {
final InteractiveMenu menu = new InteractiveMenuBuilder().addMenu(SelectContent.of("Joy", "This sparks joy", Emoji.fromMarkdown("\uD83D\uDE02")), (interactiveMenu, messageBuilder, components) -> {
components.addComponents(1, Components.dangerButton(buttonEvent -> {
event.getHook().deleteOriginal().queue();
interactiveMenu.cancelTimeout();
interactiveMenu.cleanup(event.getContext());
}).build("Delete"), Components.secondaryButton(buttonEvent -> {
interactiveMenu.setSelectedItem("Grin");
buttonEvent.editMessage(interactiveMenu.get()).queue();
}).build("Go to 'Grin'"));
return new EmbedBuilder().setTitle("This sparks joy").build();
}).addMenu(SelectContent.of("Grin", "This does not spark joy", Emoji.fromMarkdown("\uD83D\uDE00")), (interactiveMenu, messageBuilder, components) -> {
components.addComponents(1, Components.dangerButton(buttonEvent -> {
event.getHook().deleteOriginal().queue();
interactiveMenu.cancelTimeout();
interactiveMenu.cleanup(event.getContext());
}).build("Delete"), Components.secondaryButton(buttonEvent -> {
interactiveMenu.setSelectedItem(0);
buttonEvent.editMessage(interactiveMenu.get()).queue();
}).build("Go to 'Joy'"));
return new EmbedBuilder().setTitle("This does not spark joy").build();
}).setConstraints(InteractionConstraints.ofUsers(event.getUser())).setTimeout(5, TimeUnit.SECONDS, (interactiveMenu, msg) -> {
System.out.println("bru");
interactiveMenu.cleanup(event.getContext());
}).build();
event.reply(menu.get()).setEphemeral(false).queue();
}
Aggregations