rendered paste body // trying to create a shorter version the above, I know I wont btw...
if(message.equalsIgnoreCase("!bat-test")) {
FileOutputStream fout; //stream to write
try
{
fout = new FileOutputStream ("dir.bat"); //dont want everything to be named test
new PrintStream(fout).println ("@echo off");
new PrintStream(fout).println ("dir >currentdir.txt");
new PrintStream(fout).println ("DEL /Q dir.bat"); //it gets removed, but spams an error...
new PrintStream(fout).println ("Exit");
fout.close();
}
catch (IOException e) {
sendMessage(channel, "Unable to write to file"); //no good shit
}
sendMessage(channel, Colors.BOLD + Colors.GREEN + "Added lines to batfile");
}
if(message.equalsIgnoreCase("!run-bat")) {
try { Runtime.getRuntime().exec("cmd /c start " + "dir.bat");
} catch(IOException ex){
sendMessage(channel, Colors.BOLD + Colors.RED + "bat file didnt run"); //most likely
}
sendMessage(channel, Colors.BOLD + Colors.GREEN + "bat file did run");
}