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