Fixed the issue that caused the process runtime to not account for arguments correctly inside the HeartbeatTask
All checks were successful
Production deployment / Build (push) Successful in 1m49s
Production deployment / Deploying (push) Successful in 16s

This commit was merged in pull request #8.
This commit is contained in:
2023-09-17 15:00:39 +02:00
parent f4b5a143b0
commit 4318d6be29

View File

@@ -5,6 +5,7 @@ import net.dv8tion.jda.api.events.GatewayPingEvent;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TimerTask;
@@ -22,8 +23,10 @@ public class HeartbeatTask extends TimerTask {
long ping = JdrBot.jda.getGatewayPing();
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) {
System.out.println("DEBUG: Ran command \""+ Arrays.toString(commandToRun) + "\"");
try (InputStream inputStream = p.getInputStream(); Scanner s = new Scanner(inputStream).useDelimiter("\\A")) {
System.out.println(s.hasNext() ? s.next() : "");
} catch (IOException e) {