SHARE
TWEET

Discord Status API

Comu May 25th, 2020 (edited) 1,184 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /*
  3. * Made by Swag
  4. */
  5.    private String getDiscordStatus() {
  6.         try {
  7.             URL url = new URL("https://srhpyqt94yxb.statuspage.io/api/v2/summary.json");
  8.             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  9.             connection.setRequestMethod("GET");
  10.             connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/0.0.306 Chrome/78.0.3904.130 Electron/7.1.11 Safari/537.36");
  11.             connection.setRequestProperty("Content-Type", "application/json");
  12.             if (connection.getResponseCode() >= 200) {
  13.                 InputStream inputStream = connection.getInputStream();
  14.                 BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
  15.                 StringBuilder sb = new StringBuilder();
  16.                 String line;
  17.                 while ((line = br.readLine()) != null) {
  18.                     sb.append(line);
  19.                 }
  20.                 br.close();
  21.                 connection.disconnect();
  22.                 if (sb.toString().substring(0, 301).contains("operational")) {
  23.                     return "Operational";
  24.                 } else {
  25.                     return "Down";
  26.                 }
  27.             } else {
  28.                 System.out.println(connection.getResponseMessage());
  29.                 connection.disconnect();
  30.             }
  31.  
  32.         } catch (MalformedURLException ex) {
  33.             ex.printStackTrace();
  34.             return "Malformed URL";
  35.         } catch (IOException ex) {
  36.             ex.printStackTrace();
  37.             return "IOException";
  38.         }
  39.         return null;
  40.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top