RustCON JS is a JavaScript library for interacting with Rust servers via WebSockets (Web RCON)
Also works on browsers and Deno!
npm install rustcon-js
yarn add rustcon-js
pnpm add rustcon-js
bun add rustcon-js
Also available via Deno package manager.
import { RconConnection } from "https://deno.land/x/rustcon/mod.ts";
import { RconConnection } from "rustcon-js";
// import { RconConnection } from "https://deno.land/x/rustcon/mod.ts";
const connection = new RconConnection({
ip: "127.0.0.1",
port: 28016, // Optional, default is 28016
password: "password"
});
connection.on("connected", async () => {
console.log("Connected to the Rust server!");
const response = await connection.send("say Hello from RustCON JS!");
console.log("Response from the Rust server:", response);
const serverInfo = await connection.server.getInfo();
console.log("Server info:", serverInfo);
const playerList = await connection.players.getAll();
console.log("Player list:", playerList);
setTimeout(() => {
connection.disconnect();
}, 10000);
});
connection.on("message", (message) => {
console.log("Message from the Rust server:", message);
});
connection.on("error", (error) => {
console.error("An error occurred:", error);
});
connection.on("disconnected", () => {
console.log("Disconnected from the Rust server!");
});
connection.connect();