io.github.freya022.botcommands.api.commands.prefixed.builder.TextCommandOptionAggregateBuilder.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.commands.prefixed.builder
import io.github.freya022.botcommands.api.commands.builder.CustomOptionBuilder
import io.github.freya022.botcommands.api.commands.prefixed.TextGeneratedValueSupplier
import io.github.freya022.botcommands.api.core.options.builder.OptionAggregateBuilder
import io.github.freya022.botcommands.internal.parameters.AggregatorParameter
import io.github.freya022.botcommands.internal.utils.toDiscordString
import kotlin.reflect.KFunction
class TextCommandOptionAggregateBuilder internal constructor(
aggregatorParameter: AggregatorParameter,
aggregator: KFunction<*>
) : OptionAggregateBuilder(aggregatorParameter, aggregator) {
@JvmOverloads
fun option(declaredName: String, optionName: String = declaredName.toDiscordString(), block: TextCommandOptionBuilder.() -> Unit = {}) {
this += TextCommandOptionBuilder(aggregatorParameter.toOptionParameter(aggregator, declaredName), optionName).apply(block)
}
fun customOption(declaredName: String) {
this += CustomOptionBuilder(aggregatorParameter.toOptionParameter(aggregator, declaredName))
}
fun generatedOption(declaredName: String, generatedValueSupplier: TextGeneratedValueSupplier) {
this += TextGeneratedOptionBuilder(aggregatorParameter.toOptionParameter(aggregator, declaredName), generatedValueSupplier)
}
@JvmOverloads
fun nestedOptionVararg(declaredName: String, amount: Int, requiredAmount: Int, optionNameSupplier: (Int) -> String, block: TextCommandOptionBuilder.(Int) -> Unit = {}) {
//Same as in TextCommandVariationBuilder#optionVararg
nestedVarargAggregate(declaredName) {
for (i in 0..= requiredAmount
}
}
}
}
override fun constructNestedAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) =
TextCommandOptionAggregateBuilder(aggregatorParameter, aggregator)
}