io.github.freya022.botcommands.api.pagination.interactive.BasicInteractiveMenuBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of BotCommands Show documentation
Show all versions of BotCommands Show documentation
A Kotlin-first (and Java) framework that makes creating Discord bots a piece of cake, using the JDA library.
package io.github.freya022.botcommands.api.pagination.interactive;
import io.github.freya022.botcommands.api.components.Components;
import io.github.freya022.botcommands.api.pagination.paginator.BasicPaginatorBuilder;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.interactions.components.selections.SelectOption;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* @param Type of the implementor
* @param Type of the implementor {@link #build()} return type
*/
@SuppressWarnings("unchecked")
public abstract class BasicInteractiveMenuBuilder, R extends BasicInteractiveMenu> extends BasicPaginatorBuilder {
protected final List> items = new ArrayList<>();
protected boolean usePaginator = false;
protected BasicInteractiveMenuBuilder(@NotNull Components componentsService) {
super(componentsService);
}
/**
* Adds a menu to this {@link InteractiveMenu}
*
Note: The first added menu will be the first selected one
*
* @param content The content of the {@link SelectOption} bound to this menu
* @param supplier The interactive menu supplier for this menu's page
*
* @return This builder for chaining convenience
*
* @see SelectContent#of(String, String, Emoji)
*/
public T addMenu(@NotNull SelectContent content, int maxPages, @NotNull InteractiveMenuSupplier supplier) {
items.add(new InteractiveMenuItem<>(content, maxPages, supplier));
return (T) this;
}
/**
* Sets whether the paginator buttons (previous, next, delete, etc...) should appear with this interactive menu
*
This is disabled by default
*
* @param usePaginator {@code true} to use the paginator buttons
*
* @return This builder for chaining convenience
*/
public T usePaginator(boolean usePaginator) {
this.usePaginator = usePaginator;
return (T) this;
}
}