use of com.freya02.botcommands.api.application.slash.annotations.JDASlashCommand in project BotCommands by freya022.
the class PaginatorCommand method run.
@JDASlashCommand(name = "paginator")
public void run(GuildSlashEvent event) {
final List<EmbedBuilder> embedBuilders = new ArrayList<>();
// Let's suppose you generated embeds like in JDA-U, so you'd have a collection of embeds to present
for (int i = 0; i < 5; i++) {
embedBuilders.add(new EmbedBuilder().setTitle("Page #" + (i + 1)));
}
final Paginator paginator = new PaginatorBuilder().setConstraints(InteractionConstraints.ofUsers(event.getUser())).useDeleteButton(false).setMaxPages(5).setPaginatorSupplier((instance, messageBuilder, components, page) -> embedBuilders.get(page).build()).build();
// You must send the paginator as a message
event.reply(paginator.get()).setEphemeral(true).queue();
}
use of com.freya02.botcommands.api.application.slash.annotations.JDASlashCommand 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