diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt index a23330a58..c36120749 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/Command.kt @@ -15,6 +15,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import net.mamoe.mirai.console.MiraiConsole import net.mamoe.mirai.console.plugins.PluginBase +import net.mamoe.mirai.message.data.Message +import java.lang.reflect.Member import kotlin.reflect.KProperty internal const val FOR_BINARY_COMPATIBILITY = "for binary compatibility" @@ -28,18 +30,19 @@ interface Command { val owner: CommandOwner val descriptor: CommandDescriptor - /* - @Deprecated(FOR_BINARY_COMPATIBILITY, level = DeprecationLevel.HIDDEN) - suspend fun onCommand(sender: CommandSender, args: List): Boolean { - return true - }*/ + /** + * 指令的默认执行方法 + * 当所有的 sub 方法均不满足时, 原始参数将送到此方法调用 + * 如果 arg 为 String, 他会被包装为 PlainText(AKA PlainMessage) + */ + suspend fun CommandSender.onDefault(args: List): Boolean /** - * 执行这个指令. + * 在更多的情况下, 你应当使用 @SubCommand 来注册一共 sub 指令 */ - suspend fun CommandSender.onCommand(args: CommandArgs): Boolean } + /** * 指令实际参数列表. 参数顺序与 [Command.descriptor] 的 [CommandDescriptor.params] 相同. */