Fix HelpCommand

This commit is contained in:
Him188 2020-10-30 10:54:40 +08:00
parent ec747979a6
commit f7c8534b4e
2 changed files with 10 additions and 5 deletions

View File

@ -76,8 +76,13 @@ public object BuiltInCommands {
@Handler
public suspend fun CommandSender.handle() {
sendMessage(
allRegisteredCommands.joinToString("\n\n") { "${it.usage}" }.lines().filterNot(String::isBlank)
.joinToString("\n")
allRegisteredCommands
.joinToString("\n\n") { command ->
val lines = command.usage.lines()
if (lines.isEmpty()) "/${command.primaryName} ${command.description}"
else
"" + lines.first() + "\n" + lines.drop(1).joinToString("\n") { " $it" }
}.lines().filterNot(String::isBlank).joinToString("\n")
)
}
}

View File

@ -153,13 +153,13 @@ internal class CommandReflector(
} else {
append(CommandManager.commandPrefix)
}
if (command is CompositeCommand) {
//if (command is CompositeCommand) {
append(command.primaryName)
append(" ")
}
//}
append(subcommand.valueParameters.joinToString(" ") { it.render() })
annotationResolver.getDescription(command, subcommand.originFunction)?.let { description ->
append(" ")
append(" # ")
append(description)
}
}