Ok so few things.. there’s a pretty well coded plugin that handles user roles and permissions: https://wordpress.org/plugins/user-role-editor/
If you’d like to do this programatically though, you should:
<?php
function wpcodex_set_capabilities(){
global $wp_roles; // global class wp-includes/capabilities.php
$role="editor";
$cap = 'publish_pages';
$wp_roles->remove_cap( $role, $cap );
}
add_action( 'init', 'wpcodex_set_capabilities' );
?>
Lmk if that does it 🙂