@Deprecated public static String escapeString(String string){
  List<String> urls=new ArrayList<>();
  Matcher matcher=URL_PATTERN.matcher(string);
  while (matcher.find()) {
    int matchStart=matcher.start(1);
    int matchEnd=matcher.end();
    String url=string.substring(matchStart,matchEnd);
    urls.add(url);
    string=matcher.replaceFirst("@@URL" + (urls.size() - 1) + "@@");
  }
  string=StringEscapeUtils.escapeJson(string);
  for (int i=0; i < urls.size(); i++) {
    string=string.replace("@@URL" + i + "@@"," " + urls.get(i));
  }
  return string;
}

@ Deprecated public static String escapeString ( String string ) { List < String > urls = new ArrayList < > ( ) ; Matcher matcher = URL_PATTERN . matcher ( string ) ; while ( matcher . find ( ) ) { int matchStart = matcher . start ( 1 ) ; int matchEnd = matcher . end ( ) ; String url = string . substring ( matchStart , matchEnd ) ; urls . add ( url ) ; string = matcher . replaceFirst ( "@@URL" + ( urls . size ( ) - 1 ) + "@@" ) ; } string = StringEscapeUtils . escapeJson ( string ) ; for ( int i = 0 ; i < urls . size ( ) ; i ++ ) { string = string . replace ( "@@URL" + i + "@@" , " " + urls . get ( i ) ) ; } return string ; }
escapes a string to ensure that the discord websocket receives it correctly .
