get Discussion setting in wordpress

this code may help you

$status = get_option('comment_registration');
// 1 : Yes , user must be registered and logged in for commenting
// 0 : No (default)

You can use the following code for the comment section

if (comments_open($postId)) {
    if (get_option('comment_registration') == 0 || is_user_logged_in() ){
      //render comments section
    }else{
        echo "You must login first";
    }
}else{
    echo "comments are closed";
}

also you can see other options in https://codex.wordpress.org/Option_Reference