mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Fix CommandCallResolver on unresolved command
This commit is contained in:
parent
29070309f1
commit
9d1294603d
@ -28,7 +28,7 @@ import net.mamoe.mirai.message.data.asMessageChain
|
|||||||
@ExperimentalCommandDescriptors
|
@ExperimentalCommandDescriptors
|
||||||
public object BuiltInCommandCallResolver : CommandCallResolver {
|
public object BuiltInCommandCallResolver : CommandCallResolver {
|
||||||
override fun resolve(call: CommandCall): CommandResolveResult {
|
override fun resolve(call: CommandCall): CommandResolveResult {
|
||||||
val callee = CommandManager.matchCommand(call.calleeName) ?: return CommandResolveResult(null)
|
val callee = CommandManager.matchCommand(call.calleeName) ?: return CommandResolveResult(CommandExecuteResult.UnresolvedCommand(call))
|
||||||
|
|
||||||
val valueArguments = call.valueArguments
|
val valueArguments = call.valueArguments
|
||||||
val context = callee.safeCast<CommandArgumentContextAware>()?.context
|
val context = callee.safeCast<CommandArgumentContextAware>()?.context
|
||||||
|
@ -32,11 +32,11 @@ public class CommandResolveResult private constructor(
|
|||||||
public val failure: CommandExecuteResult.Failure?
|
public val failure: CommandExecuteResult.Failure?
|
||||||
get() = value.safeCast()
|
get() = value.safeCast()
|
||||||
|
|
||||||
public constructor(call: ResolvedCommandCall?) : this(call as Any?)
|
public constructor(call: ResolvedCommandCall) : this(call as Any?)
|
||||||
public constructor(failure: CommandExecuteResult.Failure) : this(failure as Any)
|
public constructor(failure: CommandExecuteResult.Failure) : this(failure as Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalCommandDescriptors::class)
|
@ExperimentalCommandDescriptors
|
||||||
public inline fun <R> CommandResolveResult.fold(
|
public inline fun <R> CommandResolveResult.fold(
|
||||||
onSuccess: (ResolvedCommandCall?) -> R,
|
onSuccess: (ResolvedCommandCall?) -> R,
|
||||||
onFailure: (CommandExecuteResult.Failure) -> R,
|
onFailure: (CommandExecuteResult.Failure) -> R,
|
||||||
@ -50,9 +50,9 @@ public inline fun <R> CommandResolveResult.fold(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalCommandDescriptors::class)
|
@ExperimentalCommandDescriptors
|
||||||
public inline fun CommandResolveResult.getOrElse(
|
public inline fun CommandResolveResult.getOrElse(
|
||||||
onFailure: (CommandExecuteResult.Failure) -> ResolvedCommandCall,
|
onFailure: (CommandExecuteResult.Failure) -> ResolvedCommandCall?,
|
||||||
): ResolvedCommandCall {
|
): ResolvedCommandCall {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(onFailure, InvocationKind.AT_MOST_ONCE)
|
callsInPlace(onFailure, InvocationKind.AT_MOST_ONCE)
|
||||||
|
Loading…
Reference in New Issue
Block a user