Skip to content

Commit

Permalink
War room delete with filter cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed May 4, 2024
1 parent 6dd2944 commit 4b70fa6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Integer, WarCategory.WarRoom> entry : new HashMap<>(warCat.getWarRoomMap()).entrySet()) {
WarCategory.WarRoom room = entry.getValue();
if (room.channel == null) continue;
Expand All @@ -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<DBNation> enemy_rooms) {
int count = 0;
for (Map.Entry<Integer, WarCategory.WarRoom> 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)
Expand Down

0 comments on commit 4b70fa6

Please sign in to comment.