From 2d35642e0137960c83baaf018b32e88bd8b6ffa7 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 22 Jun 2020 04:04:38 +0200 Subject: [PATCH 1/2] Improve handling of Activity. --- .../jagrosh/jdautilities/command/impl/CommandClientImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java b/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java index 77abf63b..3d72fd7b 100644 --- a/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java +++ b/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java @@ -473,6 +473,10 @@ private void onReady(ReadyEvent event) return; } textPrefix = prefix.equals(DEFAULT_PREFIX) ? "@"+event.getJDA().getSelfUser().getName()+" " : prefix; + + if(status != null) + event.getJDA.getPresence().setOnlineStatus(status); + event.getJDA().getPresence().setPresence(status==null ? OnlineStatus.ONLINE : status, activity ==null ? null : "default".equals(activity.getName()) ? Activity.playing("Type "+textPrefix+helpWord) : activity); From a0e70699ac668cbe4a875ac724c9846d7a6cb105 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 22 Jun 2020 04:14:58 +0200 Subject: [PATCH 2/2] Make JDA Utils only set Activity when set. --- .../jdautilities/command/CommandClientBuilder.java | 2 +- .../jdautilities/command/impl/CommandClientImpl.java | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java b/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java index 98c54916..88505c3d 100644 --- a/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java +++ b/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java @@ -223,7 +223,7 @@ public CommandClientBuilder setEmojis(String success, String warning, String err /** * Sets the {@link net.dv8tion.jda.api.entities.Activity Game} to use when the bot is ready. - *
Can be set to {@code null} for no activity. + *
Can be set to {@code null} for JDA Utilities to not set it. * * @param activity * The Game to use when the bot is ready diff --git a/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java b/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java index 3d72fd7b..c819fac3 100644 --- a/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java +++ b/command/src/main/java/com/jagrosh/jdautilities/command/impl/CommandClientImpl.java @@ -474,11 +474,9 @@ private void onReady(ReadyEvent event) } textPrefix = prefix.equals(DEFAULT_PREFIX) ? "@"+event.getJDA().getSelfUser().getName()+" " : prefix; - if(status != null) - event.getJDA.getPresence().setOnlineStatus(status); - - event.getJDA().getPresence().setPresence(status==null ? OnlineStatus.ONLINE : status, - activity ==null ? null : "default".equals(activity.getName()) ? Activity.playing("Type "+textPrefix+helpWord) : activity); + if(activity != null) + event.getJDA().getPresence().setPresence(status==null ? OnlineStatus.ONLINE : status, + "default".equals(activity.getName()) ? Activity.playing("Type "+textPrefix+helpWord) : activity); // Start SettingsManager if necessary GuildSettingsManager manager = getSettingsManager();