From 448f98ba354ba62b3a1057081f5b5a74ca161cfc Mon Sep 17 00:00:00 2001 From: floppydiskette Date: Tue, 27 Aug 2024 01:33:14 +0100 Subject: [PATCH] Minor edits --- .../doki/commands/{ => levelling}/Leaderboard.java | 2 +- .../net/hypr/doki/commands/{ => levelling}/Rank.java | 2 +- .../net/hypr/doki/commands/{ => utils}/About.java | 2 +- .../java/net/hypr/doki/commands/{ => utils}/Ping.java | 2 +- .../net/hypr/doki/commands/{ => utils}/WhoIs.java | 2 +- .../net/hypr/doki/listeners/LevellingListener.java | 11 ++++++++++- 6 files changed, 15 insertions(+), 6 deletions(-) rename src/main/java/net/hypr/doki/commands/{ => levelling}/Leaderboard.java (98%) rename src/main/java/net/hypr/doki/commands/{ => levelling}/Rank.java (98%) rename src/main/java/net/hypr/doki/commands/{ => utils}/About.java (98%) rename src/main/java/net/hypr/doki/commands/{ => utils}/Ping.java (95%) rename src/main/java/net/hypr/doki/commands/{ => utils}/WhoIs.java (98%) diff --git a/src/main/java/net/hypr/doki/commands/Leaderboard.java b/src/main/java/net/hypr/doki/commands/levelling/Leaderboard.java similarity index 98% rename from src/main/java/net/hypr/doki/commands/Leaderboard.java rename to src/main/java/net/hypr/doki/commands/levelling/Leaderboard.java index 31f7197..3f8d523 100644 --- a/src/main/java/net/hypr/doki/commands/Leaderboard.java +++ b/src/main/java/net/hypr/doki/commands/levelling/Leaderboard.java @@ -1,4 +1,4 @@ -package net.hypr.doki.commands; +package net.hypr.doki.commands.levelling; import com.freya02.botcommands.api.annotations.CommandMarker; import com.freya02.botcommands.api.prefixed.CommandEvent; diff --git a/src/main/java/net/hypr/doki/commands/Rank.java b/src/main/java/net/hypr/doki/commands/levelling/Rank.java similarity index 98% rename from src/main/java/net/hypr/doki/commands/Rank.java rename to src/main/java/net/hypr/doki/commands/levelling/Rank.java index 2a48361..a9a66be 100644 --- a/src/main/java/net/hypr/doki/commands/Rank.java +++ b/src/main/java/net/hypr/doki/commands/levelling/Rank.java @@ -1,4 +1,4 @@ -package net.hypr.doki.commands; +package net.hypr.doki.commands.levelling; import com.freya02.botcommands.api.annotations.CommandMarker; import com.freya02.botcommands.api.prefixed.BaseCommandEvent; diff --git a/src/main/java/net/hypr/doki/commands/About.java b/src/main/java/net/hypr/doki/commands/utils/About.java similarity index 98% rename from src/main/java/net/hypr/doki/commands/About.java rename to src/main/java/net/hypr/doki/commands/utils/About.java index dadd972..ec455d7 100644 --- a/src/main/java/net/hypr/doki/commands/About.java +++ b/src/main/java/net/hypr/doki/commands/utils/About.java @@ -1,4 +1,4 @@ -package net.hypr.doki.commands; +package net.hypr.doki.commands.utils; import com.freya02.botcommands.api.annotations.CommandMarker; import com.freya02.botcommands.api.prefixed.CommandEvent; diff --git a/src/main/java/net/hypr/doki/commands/Ping.java b/src/main/java/net/hypr/doki/commands/utils/Ping.java similarity index 95% rename from src/main/java/net/hypr/doki/commands/Ping.java rename to src/main/java/net/hypr/doki/commands/utils/Ping.java index d2e58e1..2234ee6 100644 --- a/src/main/java/net/hypr/doki/commands/Ping.java +++ b/src/main/java/net/hypr/doki/commands/utils/Ping.java @@ -1,4 +1,4 @@ -package net.hypr.doki.commands; +package net.hypr.doki.commands.utils; import com.freya02.botcommands.api.annotations.CommandMarker; import com.freya02.botcommands.api.prefixed.CommandEvent; diff --git a/src/main/java/net/hypr/doki/commands/WhoIs.java b/src/main/java/net/hypr/doki/commands/utils/WhoIs.java similarity index 98% rename from src/main/java/net/hypr/doki/commands/WhoIs.java rename to src/main/java/net/hypr/doki/commands/utils/WhoIs.java index 70133f2..ca02f86 100644 --- a/src/main/java/net/hypr/doki/commands/WhoIs.java +++ b/src/main/java/net/hypr/doki/commands/utils/WhoIs.java @@ -1,4 +1,4 @@ -package net.hypr.doki.commands; +package net.hypr.doki.commands.utils; import com.freya02.botcommands.api.annotations.CommandMarker; import com.freya02.botcommands.api.prefixed.BaseCommandEvent; diff --git a/src/main/java/net/hypr/doki/listeners/LevellingListener.java b/src/main/java/net/hypr/doki/listeners/LevellingListener.java index 6442c7f..2568523 100644 --- a/src/main/java/net/hypr/doki/listeners/LevellingListener.java +++ b/src/main/java/net/hypr/doki/listeners/LevellingListener.java @@ -19,11 +19,20 @@ public class LevellingListener extends ListenerAdapter { @Override public void onMessageReceived(MessageReceivedEvent event) { Logger log = Logging.getLogger(); + /* Ignore the message if one of the following conditions is met: - Message is from self user - - Message is from bot + - Message is from a bot - Message is command (starts with bot prefix) + - Message is a Direct Message to the bot */ + try { + event.getGuild(); + } catch (IllegalStateException ex) { + log.debug("Ignoring direct message with ID {}", event.getMessageId()); + return; + } + if ( Doki.getJDA().getSelfUser().getId().equals(event.getAuthor().getId()) || event.getAuthor().isBot() ||