19 lines
425 B
TypeScript
19 lines
425 B
TypeScript
|
|
import { Rcon } from "rcon-client";
|
||
|
|
import { MC_SERVER_IP, RCON_PORT, RCON_PASSWORD } from "./constants";
|
||
|
|
|
||
|
|
export async function sendCommand(command: string): Promise<string> {
|
||
|
|
const rcon = await Rcon.connect({
|
||
|
|
host: MC_SERVER_IP,
|
||
|
|
port: RCON_PORT,
|
||
|
|
password: RCON_PASSWORD,
|
||
|
|
timeout: 5000,
|
||
|
|
});
|
||
|
|
|
||
|
|
try {
|
||
|
|
const response = await rcon.send(command);
|
||
|
|
return response;
|
||
|
|
} finally {
|
||
|
|
rcon.end();
|
||
|
|
}
|
||
|
|
}
|