Update rich presence only gets displayed if a major update was released

This commit is contained in:
ByteDream 2020-12-10 20:09:11 +01:00
parent 2de12fbbbf
commit 2bb7834e13

View File

@ -53,6 +53,7 @@ public class Discord {
* @since 1.1
*/
private void updateRichPresence() {
if (Main.version.replace(".", "").length() == Main.version.length() - 1) { // only gets executed on major updates
try {
HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/ByteDream/untisbot-discord/releases/tags/v" + Main.version).openConnection();
connection.connect();
@ -66,9 +67,9 @@ public class Discord {
if (ChronoUnit.DAYS.between(now, releaseDateTime) == 0) {
if (jda != null) {
jda.getPresence().setActivity(Activity.playing("update " + Main.version + " („\\(^_^)/“)"));
jda.getPresence().setActivity(Activity.playing("update " + Main.version + " \uD83C\uDF89"));
} else {
jdaBuilder.setActivity(Activity.playing("update " + Main.version + " („\\(^_^)/“)"));
jdaBuilder.setActivity(Activity.playing("update " + Main.version + " \uD83C\uDF89"));
}
new Timer().schedule(new TimerTask() {
@Override
@ -86,6 +87,7 @@ public class Discord {
e.printStackTrace();
}
}
}
/**
* Starts the bot