feat: bootの対応

This commit is contained in:
Keisuke Hirata 2025-12-07 04:20:43 +09:00
parent 3671948bfe
commit e0613cd052
2 changed files with 19 additions and 0 deletions

View File

@ -23,6 +23,20 @@ object WordArgumentType : KommandArgumentType<String> {
}
}
object BooleanArgumentType : KommandArgumentType<Boolean> {
override fun parse(input: String, context: KommandContext): ArgumentParseResult<Boolean> {
val lower = input.lowercase()
return when (lower) {
"true" -> ArgumentParseResult.Success(true)
"false" -> ArgumentParseResult.Success(false)
else -> ArgumentParseResult.Failure("Expected true/false but got '$input'")
}
}
override fun suggestions(context: KommandContext, prefix: String): List<String> =
listOf("true", "false").filter { it.startsWith(prefix, ignoreCase = true) }
}
class IntegerArgumentType(
val min: Int? = null,
val max: Int? = null

View File

@ -147,6 +147,11 @@ abstract class BranchScope internal constructor(
block: ValueBuilder<Double>.() -> Unit = {}
) = argument(name, FloatArgumentType(min, max), block)
fun bool(
name: String,
block: ValueBuilder<Boolean>.() -> Unit = {}
) = argument(name, BooleanArgumentType, block)
fun player(
name: String,
allowSelectors: Boolean = true,