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

io.github.freya022.botcommands.api.pagination.custom.CustomPagination.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.custom

import io.github.freya022.botcommands.api.core.BContext
import io.github.freya022.botcommands.api.pagination.Paginators
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder

/**
 * Classic paginator, where each page is generated by a [CustomPageEditor].
 *
 * @see Paginators.customPagination
 * @see Paginators.singlePage
 */
class CustomPagination internal constructor(
    context: BContext,
    builder: CustomPaginationBuilder
) : AbstractCustomPagination(
    context,
    builder
) {
    private val editor: CustomPageEditor = builder.pageEditor

    override var maxPages: Int = builder.maxPages
        public set(value) {
            require(maxPages > 0) { "Max pages must be > 0" }
            field = value
        }

    override fun writeMessage(builder: MessageCreateBuilder) {
        editor.accept(this, builder, page)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy