Skip to content

Commit

Permalink
Timeout member for 30 seconds if doing unnecessary ping
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgeiss0702 committed Aug 28, 2023
1 parent 565c4d8 commit 74b30f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/us/ajg0702/bots/ajsupport/MessageListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -130,12 +131,14 @@ public void onMessageReceived(@NotNull MessageReceivedEvent e) {
"In the future, please be patient and wait for a response.")
.queue();
}
e.getMember().timeoutFor(Duration.ofSeconds(30)).queue();
}

if(hasRole(mentionedMember, 615721804585107477L) && e.getMessage().getMessageReference() == null) {
Long last = lastAjMentionWarns.getOrDefault(e.getChannel().getIdLong(), 0L);
lastAjMentionWarns.put(e.getChannel().getIdLong(), System.currentTimeMillis());
if(System.currentTimeMillis() - last > 15000) {
long distanceSinceLast = System.currentTimeMillis() - last;
if(distanceSinceLast > 15000) {
e.getMessage().reply(
"Please don't ping aj!\n" +
"\naj has all notifications on, so he will see your message without you needing to ping him.\n" +
Expand All @@ -144,6 +147,7 @@ public void onMessageReceived(@NotNull MessageReceivedEvent e) {
"In the future, please be patient and wait for a response. (without pinging)")
.queue();
}
e.getMember().timeoutFor(Duration.ofSeconds(30)).queue();
}
}
}
Expand Down

0 comments on commit 74b30f9

Please sign in to comment.