Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- //checking online status
- boolean online = twitchClient.getStreamEndpoint().isLive(channelEndpoint.getChannel());
- System.out.println(counter+" "+channelTwitch.getName() + " is online: " + online);
- //comparing it to the status in loop before and sending a message if status changed
- if (online && !before) {
- for (TextChannel channel : announcements)
- channel.sendMessage("@everyone " + channelTwitch.getName() + " is online playing "+channelTwitch.getGame() + "! \n" + channelTwitch.getUrl()).queue();
- }
- if (!online && before) {
- for (TextChannel channel : announcements)
- channel.sendMessage(channelTwitch.getName() + " went offline :(").queue();
- }
- //saving current status for comparison in next loop
- before = online;
- //wait
- Thread.sleep(45 * 1000);
- //restart
- run();
- } catch (Exception e) {
- //...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement