Fix generated usage for CompositeCommand

This commit is contained in:
Him188 2020-08-28 21:14:47 +08:00
parent a7dbe82256
commit ad53f315ac

View File

@ -12,6 +12,7 @@
package net.mamoe.mirai.console.internal.command package net.mamoe.mirai.console.internal.command
import net.mamoe.mirai.console.command.* import net.mamoe.mirai.console.command.*
import net.mamoe.mirai.console.command.Command.Companion.primaryName
import net.mamoe.mirai.console.command.description.CommandArgumentContext import net.mamoe.mirai.console.command.description.CommandArgumentContext
import net.mamoe.mirai.console.command.description.CommandArgumentContextAware import net.mamoe.mirai.console.command.description.CommandArgumentContextAware
import net.mamoe.mirai.message.data.PlainText import net.mamoe.mirai.message.data.PlainText
@ -228,7 +229,15 @@ internal fun Array<AbstractReflectionCommand.SubCommandDescriptor>.createUsage(b
internal fun AbstractReflectionCommand.SubCommandDescriptor.createUsage(baseCommand: AbstractReflectionCommand): String = internal fun AbstractReflectionCommand.SubCommandDescriptor.createUsage(baseCommand: AbstractReflectionCommand): String =
buildString { buildString {
if (!baseCommand.prefixOptional) { if (!baseCommand.prefixOptional) {
append("(")
append(CommandManager.commandPrefix) append(CommandManager.commandPrefix)
append(")")
} else {
append(CommandManager.commandPrefix)
}
if (baseCommand is CompositeCommand) {
append(baseCommand.primaryName)
append(" ")
} }
append(names.first()) append(names.first())
append(" ") append(" ")