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