diff --git a/src/main/java/com/hypherionmc/sdlink/core/config/impl/BotConfigSettings.java b/src/main/java/com/hypherionmc/sdlink/core/config/impl/BotConfigSettings.java index 8604567..150a51f 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/config/impl/BotConfigSettings.java +++ b/src/main/java/com/hypherionmc/sdlink/core/config/impl/BotConfigSettings.java @@ -19,7 +19,7 @@ public class BotConfigSettings { public String botToken = ""; @Path("statusUpdateInterval") - @SpecComment("How often the Bot Status will update on Discord (in Seconds)") + @SpecComment("How often the Bot Status will update on Discord (in Seconds). Set to 0 to disable") public int statusUpdateInterval = 30; @Path("staffRole") diff --git a/src/main/java/com/hypherionmc/sdlink/core/discord/BotController.java b/src/main/java/com/hypherionmc/sdlink/core/discord/BotController.java index 45ba693..6cd3429 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/discord/BotController.java +++ b/src/main/java/com/hypherionmc/sdlink/core/discord/BotController.java @@ -107,6 +107,7 @@ public class BotController { clientBuilder.setOwnerId("354707828298088459"); clientBuilder.setHelpWord("help"); clientBuilder.useHelpBuilder(false); + clientBuilder.setActivity(null); //clientBuilder.forceGuildOnly(750990873311051786L); CommandClient commandClient = clientBuilder.build(); diff --git a/src/main/java/com/hypherionmc/sdlink/core/discord/hooks/BotReadyHooks.java b/src/main/java/com/hypherionmc/sdlink/core/discord/hooks/BotReadyHooks.java index 33436ed..acbcc33 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/discord/hooks/BotReadyHooks.java +++ b/src/main/java/com/hypherionmc/sdlink/core/discord/hooks/BotReadyHooks.java @@ -28,28 +28,30 @@ public class BotReadyHooks { * @param event The {@link ReadyEvent} */ public static void startActivityUpdates(ReadyEvent event) { - BotController.taskManager.scheduleAtFixedRate(() -> { - try { - if (event.getJDA().getStatus() == JDA.Status.CONNECTED) { - Activity act = Activity.of(SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusType, SDLinkConfig.INSTANCE.botConfig.botStatus.botStatus - .replace("%players%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getLeft())) - .replace("%maxplayers%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getRight()))); + if (SDLinkConfig.INSTANCE.botConfig.statusUpdateInterval > 0) { + BotController.taskManager.scheduleAtFixedRate(() -> { + try { + if (event.getJDA().getStatus() == JDA.Status.CONNECTED) { + Activity act = Activity.of(SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusType, SDLinkConfig.INSTANCE.botConfig.botStatus.botStatus + .replace("%players%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getLeft())) + .replace("%maxplayers%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getRight()))); - if (SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusType == Activity.ActivityType.STREAMING) { - act = Activity.of(SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusType, SDLinkConfig.INSTANCE.botConfig.botStatus.botStatus - .replace("%players%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getLeft())) - .replace("%maxplayers%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getRight())), - SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusStreamingURL); + if (SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusType == Activity.ActivityType.STREAMING) { + act = Activity.of(SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusType, SDLinkConfig.INSTANCE.botConfig.botStatus.botStatus + .replace("%players%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getLeft())) + .replace("%maxplayers%", String.valueOf(SDLinkPlatform.minecraftHelper.getPlayerCounts().getRight())), + SDLinkConfig.INSTANCE.botConfig.botStatus.botStatusStreamingURL); + } + + event.getJDA().getPresence().setActivity(act); + } + } catch (Exception e) { + if (SDLinkConfig.INSTANCE.generalConfig.debugging) { + BotController.INSTANCE.getLogger().info(e.getMessage()); } - - event.getJDA().getPresence().setActivity(act); } - } catch (Exception e) { - if (SDLinkConfig.INSTANCE.generalConfig.debugging) { - BotController.INSTANCE.getLogger().info(e.getMessage()); - } - } - }, SDLinkConfig.INSTANCE.botConfig.statusUpdateInterval, SDLinkConfig.INSTANCE.botConfig.statusUpdateInterval, TimeUnit.SECONDS); + }, SDLinkConfig.INSTANCE.botConfig.statusUpdateInterval, SDLinkConfig.INSTANCE.botConfig.statusUpdateInterval, TimeUnit.SECONDS); + } } /**