Customizing comments pagination for bootstrap

Just replace that snippet for this one:

    <?php
      $pages = paginate_comments_links(['echo' => false, 'type' => 'array']);

      if( is_array( $pages ) ) {
        $output="";
        foreach ($pages as $page) {
          $page = "\n<li>$page</li>\n";
          if (strpos($page, ' current') !== false) 
            $page = str_replace([' current', '<li>'], ['', '<li class="active">'], $page);
          $output .= $page;
        }
        ?>
        <nav aria-label="Comment navigation">
            <ul class="pagination">
                <?=$output?>
            </ul>
        </nav>
    <?php
      }
    ?>

This code retrieves the comments as an array, this allows to customize each one as an unordered list formatted just for Bootstrap.

It also replaces the current WP class for the active that Bootstrap uses to mark the current page.

For this code to work you also need to add the bootstrap.css file in your header.

tech