diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt index c3cde4f47..116d5c068 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt @@ -256,6 +256,15 @@ internal class CommandReflector( if (instanceParameter != null) { args[instanceParameter] = command } + + val receiverParameter = function.extensionReceiverParameter + if (receiverParameter != null) { + check(receiverParameter.type.classifierAsKClass().isInstance(call.caller)) { + "Bad command call resolved. " + + "Function expects receiver parameter ${receiverParameter.type} whereas actual is ${call.caller::class}." + } + args[receiverParameter] = call.caller + } function.callSuspendBy(args) } }.toList()