From 6dd2944d4c9bc2b19b836f6abd2bdc78da1986c9 Mon Sep 17 00:00:00 2001 From: test Date: Sat, 4 May 2024 13:33:11 +1000 Subject: [PATCH] Purge war rooms (planning) --- .../manager/v2/impl/pw/CommandManager2.java | 1 + .../manager/v2/impl/pw/commands/WarCommands.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+) 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 8a283e91..c57344a8 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 @@ -184,6 +184,7 @@ public CommandManager2 registerDefaults() { getCommands().registerMethod(new IACommands(), List.of("interview", "questions"), "setInterview", "set"); 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 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 096b23c3..144b5aab 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 @@ -4286,6 +4286,21 @@ public String sortWarRooms(@Me WarCategory warCat) { return "Done! Moved " + moved + " channels"; } + @RolePermission(value = Roles.MILCOM) + @Command(desc = "Delete planning war rooms with no participants") + public String deletePlanningChannel(@Me WarCategory warCat) { + for (Map.Entry entry : new HashMap<>(warCat.getWarRoomMap()).entrySet()) { + WarCategory.WarRoom room = entry.getValue(); + if (room.channel == null) continue; + if (!room.getParticipants().isEmpty()) continue; + if (!room.isPlanning()) continue; + room.addInitialParticipants(false); + if (!room.getParticipants().isEmpty()) continue; + room.delete("Manually deleted"); + } + return "Done. Please wait for rooms to finish deleting"; + } + @RolePermission(value = Roles.MILCOM) @Command(desc = "Create a war room\n" + "Add `-p` to ping users that are added\n" +