change command structure

This commit is contained in:
jiahua.liu 2020-05-14 23:41:01 +08:00
parent 074af959ab
commit d16104b0ad

View File

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