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

io.github.freya022.botcommands.internal.commands.text.builder.TextCommandBuilderImpl.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.internal.commands.text.builder

import io.github.freya022.botcommands.api.commands.CommandType
import io.github.freya022.botcommands.api.commands.text.builder.TextCommandBuilder
import io.github.freya022.botcommands.api.commands.text.builder.TextCommandVariationBuilder
import io.github.freya022.botcommands.api.core.BContext
import io.github.freya022.botcommands.api.core.setCallerAsDeclarationSite
import io.github.freya022.botcommands.internal.commands.builder.CommandBuilderImpl
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.internal.utils.Checks
import java.util.function.Consumer
import kotlin.reflect.KFunction

internal abstract class TextCommandBuilderImpl internal constructor(
    context: BContext,
    name: String,
) : CommandBuilderImpl(context, name),
    TextCommandBuilder {

    final override val type: CommandType get() = CommandType.TEXT
    internal val subcommands: MutableList = arrayListOf()

    internal val variations: MutableList = arrayListOf()

    final override var nsfw: Boolean = false

    final override var aliases: MutableList = arrayListOf()

    final override var description: String? = null

    final override var ownerRequired: Boolean = false

    final override var hidden: Boolean = false

    init {
        Checks.matches(name, Checks.ALPHANUMERIC_WITH_DASH, "Text command name")
    }

    final override var detailedDescription: Consumer? = null

    final override fun subcommand(name: String, block: TextCommandBuilder.() -> Unit) {
        subcommands += TextSubcommandBuilderImpl(context, name, this)
            .setCallerAsDeclarationSite()
            .apply(block)
    }

    final override fun variation(function: KFunction, block: TextCommandVariationBuilder.() -> Unit) {
        variations += TextCommandVariationBuilderImpl(context, function)
            .setCallerAsDeclarationSite()
            .apply(block)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy