3131import java .time .format .DateTimeFormatter ;
3232import java .util .Collections ;
3333import java .util .HashMap ;
34+ import java .util .HashSet ;
3435import java .util .List ;
3536import java .util .Map ;
3637import java .util .Map .Entry ;
38+ import java .util .Set ;
3739import java .util .concurrent .CompletableFuture ;
38- import java .util .concurrent .CopyOnWriteArrayList ;
3940import java .util .concurrent .ExecutorService ;
4041import java .util .concurrent .atomic .AtomicBoolean ;
4142import java .util .stream .Collectors ;
@@ -48,7 +49,7 @@ public class PurgeCommand extends ModerateCommand {
4849 private static final Path ARCHIVE_DIR = Path .of ("purgeArchives" );
4950 private final ExecutorService asyncPool ;
5051
51- private final Map <Long , List <RunningPurge >> currentPurges = Collections .synchronizedMap (new HashMap <>());
52+ private final Map <Long , Set <RunningPurge >> currentPurges = Collections .synchronizedMap (new HashMap <>());
5253
5354 /**
5455 * The constructor of this class, which sets the corresponding {@link net.dv8tion.jda.api.interactions.commands.build.SlashCommandData}.
@@ -80,7 +81,7 @@ protected ReplyCallbackAction handleModerationCommand(@NotNull SlashCommandInter
8081 return Responses .warning (event , "Invalid amount. Should be between 1 and " + maxAmount + ", inclusive." );
8182 }
8283 if (amount == 0 ) {
83- List <RunningPurge > purges = currentPurges .get (event .getGuild ().getIdLong ());
84+ Set <RunningPurge > purges = currentPurges .get (event .getGuild ().getIdLong ());
8485 if (purges == null ) {
8586 return Responses .warning (event , "Cannot stop purge as no purge is currently running." );
8687 } else {
@@ -98,7 +99,7 @@ protected ReplyCallbackAction handleModerationCommand(@NotNull SlashCommandInter
9899 () -> this .purge (amount , user , event .getUser (), archive , event .getChannel (), config .getLogChannel (), runningPurge .cancelled ()),
99100 asyncPool );
100101 currentPurges
101- .computeIfAbsent (event .getGuild ().getIdLong (), l -> new CopyOnWriteArrayList <>())
102+ .computeIfAbsent (event .getGuild ().getIdLong (), l -> Collections . synchronizedSet ( new HashSet <>() ))
102103 .add (runningPurge );
103104 future .whenComplete ((success , failure ) ->
104105 currentPurges .get (event .getGuild ().getIdLong ())
0 commit comments