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

me.jakejmattson.kutils.api.arguments.CharArg.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.CommandEvent

open class CharArg(override val name: String = "Character") : ArgumentType() {
    companion object : CharArg()

    override fun convert(arg: String, args: List, event: CommandEvent<*>): ArgumentResult {
        return if (arg.length == 1)
            ArgumentResult.Success(arg[0])
        else
            ArgumentResult.Error("$name should be a single character.")
    }

    override fun generateExamples(event: CommandEvent<*>) = ('a'..'z').map { it.toString() }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy