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 @Handler
public suspend fun CommandSender.handle() { public suspend fun CommandSender.handle() {
sendMessage( sendMessage(
allRegisteredCommands.joinToString("\n\n") { "${it.usage}" }.lines().filterNot(String::isBlank) allRegisteredCommands
.joinToString("\n") .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 { } else {
append(CommandManager.commandPrefix) append(CommandManager.commandPrefix)
} }
if (command is CompositeCommand) { //if (command is CompositeCommand) {
append(command.primaryName) append(command.primaryName)
append(" ") append(" ")
} //}
append(subcommand.valueParameters.joinToString(" ") { it.render() }) append(subcommand.valueParameters.joinToString(" ") { it.render() })
annotationResolver.getDescription(command, subcommand.originFunction)?.let { description -> annotationResolver.getDescription(command, subcommand.originFunction)?.let { description ->
append(" ") append(" # ")
append(description) append(description)
} }
} }