All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.freya022.botcommands.api.pagination.menu.buttonized.ButtonMenuBuilder.kt Maven / Gradle / Ivy

Go to download

A Kotlin-first (and Java) framework that makes creating Discord bots a piece of cake, using the JDA library.

There is a newer version: 3.0.0-alpha.18
Show newest version
package io.github.freya022.botcommands.api.pagination.menu.buttonized

import io.github.freya022.botcommands.api.core.BContext
import io.github.freya022.botcommands.api.pagination.Paginators
import io.github.freya022.botcommands.api.pagination.menu.AbstractMenuBuilder

/**
 * Builds a [ButtonMenu].
 *
 * @param E Type of the entries
 *
 * @see Paginators.buttonMenu
 */
class ButtonMenuBuilder internal constructor(
    context: BContext,
    entries: List,
    val buttonContentSupplier: ButtonMenu.ButtonContentSupplier,
    val callback: SuspendingChoiceCallback
) : AbstractMenuBuilder, ButtonMenu>(context, entries) {
    var reusable: Boolean = ButtonMenu.Defaults.reusable
        private set

    /**
     * Sets whether selecting an entry invalidates this menu.
     *
     * If `true`, the buttons will only be usable once,
     * if `false`, the buttons can be clicked and callback ran multiple times.
     */
    fun setReusable(reusable: Boolean): ButtonMenuBuilder = config {
        this.reusable = reusable
    }

    override fun build(): ButtonMenu = ButtonMenu(context, this)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy