Managing Player Cache:

The bot.room.cache provides methods for managing the player cache in the room. This cache utilizes the bot's memory and enhances performance by reducing API requests. Alternatively, you can use:

Get Players In Room

Enabling Cache:

To enable the player cache, update the bot instance to include the events "Joins", "Leaves", and "Movements", and set Cache to true.

const bot = new Highrise({
  Events: [
    Events.Joins, // Listen for player joins.
    Events.Leaves, // Listen for player leaves.
    Events.Movements // Listen for player movements.
  ],
  Cache: true // Enable player cache.
});

Methods:

Retrieving Players:

Retrieves the list of players currently in the room.

// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", async (user, message) => {
  if (message === "players") {
    const players = await bot.room.cache.get();
    const playerList = players.map(player => player[0].username).join(", ");

    console.log("Players in the room: " + playerList);
  }
});

Retrieving User ID:

Retrieves the username of a player using their user ID.

// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", async (user, message) => {
  if (message === "id") {
    const playerId = await bot.room.cache.username(user.username);
    console.log(`The user's ID is: ${playerId}`);
  }
});

Retrieving Username:

Retrieves the user ID of a player using their username.

// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", async (user, message) => {
  if (message === "username") {
    const username = await bot.room.cache.id(user.id);
    console.log(`The user's username is: ${username}`);
  }
});