me.jakejmattson.kutils.api.dsl.command.CommandContainer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of KUtils Show documentation
Show all versions of KUtils Show documentation
A Discord bot framework for Kotlin.
package me.jakejmattson.kutils.api.dsl.command
fun commands(construct: CommandsContainer.() -> Unit): CommandsContainer {
val commands = CommandsContainer()
commands.construct()
return commands
}
data class CommandsContainer(val commands: MutableList = mutableListOf()) {
fun command(vararg names: String, body: Command.() -> Unit): Command {
val command = Command(names.toList())
command.body()
commands.add(command)
return command
}
operator fun plus(container: CommandsContainer) = apply { commands.addAll(container.commands) }
operator fun get(name: String) = commands.firstOrNull { name.toLowerCase() in it.names.map { it.toLowerCase() } }
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy