Fixed the issue that caused the process runtime to not account for arguments correctly inside the HeartbeatTask
This commit was merged in pull request #8.
This commit is contained in:
@@ -5,6 +5,7 @@ import net.dv8tion.jda.api.events.GatewayPingEvent;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
@@ -22,8 +23,10 @@ public class HeartbeatTask extends TimerTask {
|
|||||||
long ping = JdrBot.jda.getGatewayPing();
|
long ping = JdrBot.jda.getGatewayPing();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Process p = Runtime.getRuntime().exec(command.replaceAll("\\{ping\\}", String.valueOf(ping)));
|
String[] commandToRun = {"bash", "-c", command.replaceAll("\\{ping\\}", String.valueOf(ping))};
|
||||||
|
Process p = Runtime.getRuntime().exec(commandToRun);
|
||||||
if(JdrBot.debugMode) {
|
if(JdrBot.debugMode) {
|
||||||
|
System.out.println("DEBUG: Ran command \""+ Arrays.toString(commandToRun) + "\"");
|
||||||
try (InputStream inputStream = p.getInputStream(); Scanner s = new Scanner(inputStream).useDelimiter("\\A")) {
|
try (InputStream inputStream = p.getInputStream(); Scanner s = new Scanner(inputStream).useDelimiter("\\A")) {
|
||||||
System.out.println(s.hasNext() ? s.next() : "");
|
System.out.println(s.hasNext() ? s.next() : "");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user