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

me.jakejmattson.kutils.api.arguments.CommandArg.kt Maven / Gradle / Ivy

There is a newer version: 0.18.1
Show newest version
package me.jakejmattson.kutils.api.arguments

import me.jakejmattson.kutils.api.dsl.arguments.*
import me.jakejmattson.kutils.api.dsl.command.*

open class CommandArg(override val name: String = "Command") : ArgumentType() {
    companion object : CommandArg()

    override fun convert(arg: String, args: List, event: CommandEvent<*>): ArgumentResult {
        val command = event.container[arg.toLowerCase()]
            ?: return ArgumentResult.Error("Couldn't parse $name from $arg.")

        return ArgumentResult.Success(command)
    }

    override fun generateExamples(event: CommandEvent<*>) = event.container.commands.mapNotNull { it.names.firstOrNull() }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy