buildCommandArgumentContext
fun buildCommandArgumentContext(block: CommandArgumentContextBuilder.() -> Unit): CommandArgumentContext
构建一个 buildCommandArgumentContext.
Kotlin 实现:
val context = buildCommandArgumentContext {
Int::class with IntArgParser
Member::class with ExistingMemberArgParser
Group::class with { s: String, sender: CommandSender ->
Bot.getInstance(s.toLong()).getGroup(s.toLong())
}
Bot::class with { s: String ->
Bot.getInstance(s.toLong())
}
}
Content copied to clipboard
Java 实现:
CommandArgumentContext context =
new CommandArgumentContextBuilder()
.add(clazz1, parser1)
.add(String.class, new CommandArgumentParser<String>() {
public String parse(String raw, CommandSender sender) {
// ...
}
})
// 更多 add
.build()
Content copied to clipboard