1414import java .time .Instant ;
1515import java .util .Map ;
1616import java .util .Objects ;
17+ import java .util .Optional ;
1718import java .util .concurrent .Executors ;
1819import java .util .concurrent .ScheduledExecutorService ;
1920import java .util .concurrent .TimeUnit ;
@@ -86,14 +87,15 @@ private void processGroupedActions(@NotNull RevocationGroupIdentifier groupIdent
8687 // but also if the system automatically revoked a temp-ban already itself
8788 ModerationAction revokeActionType =
8889 getRevocableActionByType (groupIdentifier .type ).getRevokeType ();
89- ActionRecord lastRevokeAction = actionsStore
90- .findLastActionAgainstTargetByType (groupIdentifier .guildId , groupIdentifier .targetId ,
91- revokeActionType )
92- .orElseThrow ();
93- if (lastRevokeAction .issuedAt ().isAfter (lastApplyAction .issuedAt ())
94- && (lastRevokeAction .actionExpiresAt () == null
95- || lastRevokeAction .actionExpiresAt ().isAfter (Instant .now ()))) {
96- return ;
90+ Optional <ActionRecord > lastRevokeActionOpt = actionsStore .findLastActionAgainstTargetByType (
91+ groupIdentifier .guildId , groupIdentifier .targetId , revokeActionType );
92+ if (lastRevokeActionOpt .isPresent ()) {
93+ ActionRecord lastRevokeAction = lastRevokeActionOpt .orElseThrow ();
94+ if (lastRevokeAction .issuedAt ().isAfter (lastApplyAction .issuedAt ())
95+ && (lastRevokeAction .actionExpiresAt () == null
96+ || lastRevokeAction .actionExpiresAt ().isAfter (Instant .now ()))) {
97+ return ;
98+ }
9799 }
98100
99101 revokeAction (groupIdentifier );
@@ -102,7 +104,7 @@ private void processGroupedActions(@NotNull RevocationGroupIdentifier groupIdent
102104 private void revokeAction (@ NotNull RevocationGroupIdentifier groupIdentifier ) {
103105 Guild guild = jda .getGuildById (groupIdentifier .guildId );
104106 if (guild == null ) {
105- logger .info (
107+ logger .debug (
106108 "Attempted to revoke a temporary moderation action but the bot is not connected to the guild '{}' anymore, skipping revoking." ,
107109 groupIdentifier .guildId );
108110 return ;
0 commit comments