npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rce.js

v2.2.0

Published

A wrapper for Rust Console Edition (RCE) that allows you to use the websocket and API from G-Portal.

Downloads

952

Readme

rce.js

A library for developers to easily create their own Rust Console Edition integrations such as discord bots using GPORTAL's API & WebSocket!

Documentation

For a more in-depth documentation, refer to GitBook! You can also join our support discord server

Installation

npm i b1nzeex/rce.js

Example Usage - TypeScript

import { RCEManager, LogLevel, RCEEvent } from "rce.js";

const rce = new RCEManager({
  authMethod: "manual", // Can set to "manual" or "file" - manual requires a "refreshToken" in the AuthOptions and must be updated everytime you restart your application, file handles auth through a txt file which stores your refresh token
  refreshToken: "", // Obtained via the G-PORTAL website, scroll to the bottom of this documentation for a guide on obtaining this
  logLevel: LogLevel.Info, // Uses "Info" by default if left blank
  servers: [
    {
      identifier: "server1", // A unique name for your server to be recognised by
      region: "US", // It's either EU or US
      serverId: 1487554, // You can find this in the URL on your server page
      refreshPlayers: 2, // This will fetch the playerlist every 2 minutes, good for displaying player count
    },
    {
      identifier: "server2",
      region: "EU",
      serverId: 1487367,
    }, // As we didn't specify a "refreshPlayers" value, the playerlist won't be fetched
  ], // An array of servers to listen to
});

await rce.init(); // This attempts to login to GPORTAL - this is required for everything else to function

rce.on(RCEEvent.PlayerKill, (data) => {
  console.log(
    `[${data.server.identifier}] ${data.killer.name} killed ${data.victim.name}`
  );

  // Send an in-game command to the Rust server by the unique identifier (kill-feed!)
  await rce.sendCommand(
    data.server.identifier,
    `say <color=red>${data.killer.name}</color> killed <color=red>${data.victim.name}</color>`
  );
});

Example Usage - JavaScript (ES5)

const { RCEManager, LogLevel, RCEEvent } = require("rce.js");

const rce = new RCEManager({
  authMethod: "file", // Can set to "manual" or "file" - manual requires a "refreshToken" in the AuthOptions and must be updated everytime you restart your application, file handles auth through a txt file which stores your refresh token
  file: "", // By default, it will create an "auth.txt" file if not specified, otherwise you can provide your own file path
  logLevel: LogLevel.Info, // Uses "Info" by default if left blank
  servers: [
    {
      identifier: "server1", // A unique name for your server to be recognised by
      region: "US", // It's either EU or US
      serverId: 1487554, // You can find this in the URL on your server page
      refreshPlayers: 2, // This will fetch the playerlist every 2 minutes, good for displaying player count
    },
    {
      identifier: "server2",
      region: "EU",
      serverId: 1487367,
    }, // As we didn't specify a "refreshPlayers" value, the playerlist won't be fetched
  ], // An array of servers to listen to
});

await rce.init(); // This attempts to login to GPORTAL - this is required for everything else to function

rce.on(RCEEvent.PlayerKill, (data) => {
  console.log(
    `[${data.server.identifier}] ${data.killer.name} killed ${data.victim.name}`
  );

  // Send an in-game command to the Rust server by the unique identifier (kill-feed!)
  await rce.sendCommand(
    data.server.identifier,
    `say <color=red>${data.killer.name}</color> killed <color=red>${data.victim.name}</color>`
  );
});

How To Obtain G-PORTAL Refresh Token

GIF demonstrating how to obtain G-PORTAL refresh token

  • Step 1. Navigate to G-PORTAL Website
  • Step 2. Login to G-PORTAL
  • Step 3. In your browser, press CTRL + SHIFT + I all together to open the Developer Tools (inspect)
  • Step 4. Navigate to the Application tab
  • Step 5. Navigate to Local Storage
  • Step 6. Select gp-session
  • Step 7. Right click on the refresh_token and select Copy Value
  • Step 8. You're done! Now paste the refresh token into your code