Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1.         try {
  2.             //checking online status
  3.             boolean online = twitchClient.getStreamEndpoint().isLive(channelEndpoint.getChannel());
  4.             System.out.println(counter+" "+channelTwitch.getName() + " is online: " + online);
  5.                        
  6.             //comparing it to the status in loop before and sending a message if status changed
  7.             if (online && !before) {
  8.                 for (TextChannel channel : announcements)
  9.                     channel.sendMessage("@everyone " + channelTwitch.getName() + " is online playing "+channelTwitch.getGame() + "! \n" + channelTwitch.getUrl()).queue();
  10.             }
  11.             if (!online && before) {
  12.                 for (TextChannel channel : announcements)
  13.                     channel.sendMessage(channelTwitch.getName() + " went offline :(").queue();
  14.             }
  15.            
  16.             //saving current status for comparison in next loop
  17.             before = online;
  18.            
  19.             //wait
  20.             Thread.sleep(45 * 1000);
  21.            
  22.             //restart
  23.             run();
  24.         } catch (Exception e) {
  25.         //...
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement