mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
Remove CommandExecuteResult.status
This commit is contained in:
parent
5e3ffafd5a
commit
fbe5ce0970
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.console.command
|
package net.mamoe.mirai.console.command
|
||||||
|
|
||||||
import net.mamoe.mirai.console.command.CommandExecuteResult.CommandExecuteStatus
|
|
||||||
import net.mamoe.mirai.console.command.descriptor.*
|
import net.mamoe.mirai.console.command.descriptor.*
|
||||||
import net.mamoe.mirai.console.command.parse.CommandCall
|
import net.mamoe.mirai.console.command.parse.CommandCall
|
||||||
import net.mamoe.mirai.console.command.parse.CommandValueArgument
|
import net.mamoe.mirai.console.command.parse.CommandValueArgument
|
||||||
@ -29,9 +28,6 @@ import kotlin.contracts.contract
|
|||||||
@ConsoleExperimentalApi("Not yet implemented")
|
@ConsoleExperimentalApi("Not yet implemented")
|
||||||
@ExperimentalCommandDescriptors
|
@ExperimentalCommandDescriptors
|
||||||
public sealed class CommandExecuteResult {
|
public sealed class CommandExecuteResult {
|
||||||
/** 指令最终执行状态 */
|
|
||||||
public abstract val status: CommandExecuteStatus
|
|
||||||
|
|
||||||
/** 指令执行时发生的错误 (如果有) */
|
/** 指令执行时发生的错误 (如果有) */
|
||||||
public abstract val exception: Throwable?
|
public abstract val exception: Throwable?
|
||||||
|
|
||||||
@ -57,9 +53,6 @@ public sealed class CommandExecuteResult {
|
|||||||
) : CommandExecuteResult() {
|
) : CommandExecuteResult() {
|
||||||
/** 指令执行时发生的错误, 总是 `null` */
|
/** 指令执行时发生的错误, 总是 `null` */
|
||||||
public override val exception: Nothing? get() = null
|
public override val exception: Nothing? get() = null
|
||||||
|
|
||||||
/** 指令最终执行状态, 总是 [CommandExecuteStatus.SUCCESSFUL] */
|
|
||||||
public override val status: CommandExecuteStatus get() = CommandExecuteStatus.SUCCESSFUL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 指令执行失败 */
|
/** 指令执行失败 */
|
||||||
@ -75,10 +68,7 @@ public sealed class CommandExecuteResult {
|
|||||||
public override val call: CommandCall,
|
public override val call: CommandCall,
|
||||||
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
||||||
public override val resolvedCall: ResolvedCommandCall,
|
public override val resolvedCall: ResolvedCommandCall,
|
||||||
) : Failure() {
|
) : Failure()
|
||||||
/** 指令最终执行状态, 总是 [CommandExecuteStatus.EXECUTION_EXCEPTION] */
|
|
||||||
public override val status: CommandExecuteStatus get() = CommandExecuteStatus.ILLEGAL_ARGUMENT
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 指令方法调用过程出现了错误 */
|
/** 指令方法调用过程出现了错误 */
|
||||||
public class ExecutionFailed(
|
public class ExecutionFailed(
|
||||||
@ -90,10 +80,7 @@ public sealed class CommandExecuteResult {
|
|||||||
public override val call: CommandCall,
|
public override val call: CommandCall,
|
||||||
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
||||||
public override val resolvedCall: ResolvedCommandCall,
|
public override val resolvedCall: ResolvedCommandCall,
|
||||||
) : Failure() {
|
) : Failure()
|
||||||
/** 指令最终执行状态, 总是 [CommandExecuteStatus.EXECUTION_EXCEPTION] */
|
|
||||||
public override val status: CommandExecuteStatus get() = CommandExecuteStatus.EXECUTION_EXCEPTION
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 没有匹配的指令 */
|
/** 没有匹配的指令 */
|
||||||
public class UnresolvedCommand : Failure() {
|
public class UnresolvedCommand : Failure() {
|
||||||
@ -108,9 +95,6 @@ public sealed class CommandExecuteResult {
|
|||||||
|
|
||||||
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
||||||
public override val resolvedCall: ResolvedCommandCall? get() = null
|
public override val resolvedCall: ResolvedCommandCall? get() = null
|
||||||
|
|
||||||
/** 指令最终执行状态, 总是 [CommandExecuteStatus.UNRESOLVED_COMMAND] */
|
|
||||||
public override val status: CommandExecuteStatus get() = CommandExecuteStatus.UNRESOLVED_COMMAND
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 权限不足 */
|
/** 权限不足 */
|
||||||
@ -124,9 +108,6 @@ public sealed class CommandExecuteResult {
|
|||||||
) : Failure() {
|
) : Failure() {
|
||||||
/** 指令执行时发生的错误, 总是 `null` */
|
/** 指令执行时发生的错误, 总是 `null` */
|
||||||
public override val exception: Nothing? get() = null
|
public override val exception: Nothing? get() = null
|
||||||
|
|
||||||
/** 指令最终执行状态, 总是 [CommandExecuteStatus.PERMISSION_DENIED] */
|
|
||||||
public override val status: CommandExecuteStatus get() = CommandExecuteStatus.PERMISSION_DENIED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 没有匹配的指令 */
|
/** 没有匹配的指令 */
|
||||||
@ -146,32 +127,6 @@ public sealed class CommandExecuteResult {
|
|||||||
|
|
||||||
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
/** 解析的 [ResolvedCommandCall] (如果匹配到) */
|
||||||
public override val resolvedCall: ResolvedCommandCall? get() = null
|
public override val resolvedCall: ResolvedCommandCall? get() = null
|
||||||
|
|
||||||
/** 指令最终执行状态, 总是 [CommandExecuteStatus.UNMATCHED_SIGNATURE] */
|
|
||||||
public override val status: CommandExecuteStatus get() = CommandExecuteStatus.UNMATCHED_SIGNATURE
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 指令的执行状态
|
|
||||||
*/
|
|
||||||
public enum class CommandExecuteStatus {
|
|
||||||
/** 指令执行成功 */
|
|
||||||
SUCCESSFUL,
|
|
||||||
|
|
||||||
/** 指令执行过程出现了错误 */
|
|
||||||
EXECUTION_EXCEPTION,
|
|
||||||
|
|
||||||
/** 没有匹配的指令 */
|
|
||||||
UNMATCHED_SIGNATURE,
|
|
||||||
|
|
||||||
/** 没有匹配的指令 */
|
|
||||||
UNRESOLVED_COMMAND,
|
|
||||||
|
|
||||||
/** 权限不足 */
|
|
||||||
PERMISSION_DENIED,
|
|
||||||
|
|
||||||
/** 非法参数 */
|
|
||||||
ILLEGAL_ARGUMENT,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +167,6 @@ public sealed class FailureReason {
|
|||||||
public object NotEnoughArguments : ArgumentLengthMismatch()
|
public object NotEnoughArguments : ArgumentLengthMismatch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExperimentalCommandDescriptors
|
|
||||||
@Suppress("RemoveRedundantQualifierName")
|
|
||||||
public typealias CommandExecuteStatus = CommandExecuteResult.CommandExecuteStatus
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当 [this] 为 [CommandExecuteResult.Success] 时返回 `true`
|
* 当 [this] 为 [CommandExecuteResult.Success] 时返回 `true`
|
||||||
*/
|
*/
|
||||||
|
@ -13,7 +13,6 @@ import kotlinx.coroutines.*
|
|||||||
import net.mamoe.mirai.console.MiraiConsole
|
import net.mamoe.mirai.console.MiraiConsole
|
||||||
import net.mamoe.mirai.console.command.*
|
import net.mamoe.mirai.console.command.*
|
||||||
import net.mamoe.mirai.console.command.CommandExecuteResult.*
|
import net.mamoe.mirai.console.command.CommandExecuteResult.*
|
||||||
import net.mamoe.mirai.console.command.CommandExecuteResult.CommandExecuteStatus.*
|
|
||||||
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
|
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
|
||||||
import net.mamoe.mirai.console.terminal.noconsole.NoConsole
|
import net.mamoe.mirai.console.terminal.noconsole.NoConsole
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
|
Loading…
Reference in New Issue
Block a user