From 4b70fa60dbc3a45715be04097322d70d3f581ba2 Mon Sep 17 00:00:00 2001 From: test Date: Sat, 4 May 2024 13:51:42 +1000 Subject: [PATCH] War room delete with filter cmd --- .../manager/v2/impl/pw/CommandManager2.java | 1 + .../v2/impl/pw/commands/WarCommands.java | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java index c57344a8..f82f5200 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java @@ -185,6 +185,7 @@ public CommandManager2 registerDefaults() { getCommands().registerMethod(new AdminCommands(), List.of("admin", "sync"), "syncWars", "wars"); getCommands().registerMethod(new WarCommands(), List.of("war", "room"), "warRoomList", "list"); getCommands().registerMethod(new WarCommands(), List.of("war", "room"), "deletePlanningChannel", "delete_planning"); + getCommands().registerMethod(new WarCommands(), List.of("war", "room"), "deleteForEnemies", "delete_for_enemies"); getCommands().registerMethod(new UtilityCommands(), List.of("land"), "landROI", "roi"); getCommands().registerMethod(new UtilityCommands(), List.of("infra"), "infraROI", "roi"); getCommands().registerMethod(new ConflictCommands(), List.of("conflict"), "syncConflictData", "sync"); diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/WarCommands.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/WarCommands.java index 144b5aab..82f37006 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/WarCommands.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/WarCommands.java @@ -3,6 +3,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import link.locutus.discord.Locutus; import link.locutus.discord.apiv1.enums.ResourceType; +import link.locutus.discord.commands.manager.v2.impl.pw.NationFilter; import link.locutus.discord.commands.manager.v2.impl.pw.binding.NationAttributeDouble; import link.locutus.discord.commands.war.RaidCommand; import link.locutus.discord.apiv1.core.ApiKeyPool; @@ -4289,6 +4290,7 @@ public String sortWarRooms(@Me WarCategory warCat) { @RolePermission(value = Roles.MILCOM) @Command(desc = "Delete planning war rooms with no participants") public String deletePlanningChannel(@Me WarCategory warCat) { + int count = 0; for (Map.Entry entry : new HashMap<>(warCat.getWarRoomMap()).entrySet()) { WarCategory.WarRoom room = entry.getValue(); if (room.channel == null) continue; @@ -4297,8 +4299,27 @@ public String deletePlanningChannel(@Me WarCategory warCat) { room.addInitialParticipants(false); if (!room.getParticipants().isEmpty()) continue; room.delete("Manually deleted"); + count++; + } + if (count == 0) return "No channels found to delete"; + return "Done. Deleting " + count + " war rooms. Please wait for rooms to finish deleting"; + } + + @RolePermission(value = Roles.MILCOM) + @Command(desc = "Delete war rooms against the enemies specified") + public String deleteForEnemies(@Me WarCategory warCat, Set enemy_rooms) { + int count = 0; + for (Map.Entry entry : new HashMap<>(warCat.getWarRoomMap()).entrySet()) { + WarCategory.WarRoom room = entry.getValue(); + if (!enemy_rooms.contains(room.target)) continue; + room.delete("Manually deleted"); + count++; } - return "Done. Please wait for rooms to finish deleting"; + if (count == 0) return "No channels found to delete"; + return "Done. Deleting " + count + " war rooms. Please wait for rooms to finish deleting.\n\n" + + "Note: Rooms will auto create with enemies with active wars, set a filter to specify which enemies rooms are auto created for:\n" + + "- " + CM.settings_war_alerts.WAR_ROOM_FILTER.cmd.toSlashMention() + "\n" + + "- " + CM.admin.sync.warrooms.cmd.toSlashMention(); } @RolePermission(value = Roles.MILCOM)