From d6a505fd009b17dc43a3714d6b9d21c7d67880e5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Jan 2023 10:22:35 -0500 Subject: [PATCH] Added lastout sub command. --- src/discord/handlers/DevRequestHandler.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/discord/handlers/DevRequestHandler.java b/src/discord/handlers/DevRequestHandler.java index e747d73e..3fd95655 100644 --- a/src/discord/handlers/DevRequestHandler.java +++ b/src/discord/handlers/DevRequestHandler.java @@ -16,6 +16,9 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.stream.Collectors; public class DevRequestHandler { @@ -52,6 +55,9 @@ public class DevRequestHandler { case "shutdown": commandString = "./mbdevkill.sh"; break; + case "lastout": + MagicBot.sendResponse(event, getLastOutput()); + return; default: break; } @@ -74,4 +80,15 @@ public class DevRequestHandler { "Use #dev lastout to view results"); } + private static String getLastOutput() { + + String outString = null; + try { + outString = Files.lines(Paths.get("devLastOut")) + .collect(Collectors.joining(System.lineSeparator())); + } catch (IOException e) { + e.printStackTrace(); + } + return outString; + } } \ No newline at end of file