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

highrise-js-sdk

v2.2.0

Published

A JavaScript library for writing and running Highrise bots.

Downloads

67

Readme

highrise-js-sdk

The Highrise JS SDK is a JavaScript library for writing and running Highrise bots.

[IMPORTANT]: Starting from version 2.0.0, we have made changes to the event handling in the highrise-js-sdk.
This provides you with greater flexibility and control over the types of events you receive when connecting to the SDK.

⚙️ Installation

npm i highrise-js-sdk@latest

✨ Features

  • Easy to use.
  • Beginner friendly.
  • Auto reconnect system.
  • Supports Node version 10+

📥 Class Import

const { Highrise } = require("highrise-js-sdk")

const settings = {
  token: 'EXAMPLE-TOKEN',
  room: 'EXAMPLE-ROOM',
  events: ['ready', 'playerJoin', 'playerLeave', 'messages'],
  reconnect: 5
}

const client = new Highrise({ events: settings.events }, settings.reconnect);
client.login(settings.token, settings.room);

📘 Documentation

Highrise JS SDK Documentation

Event Handling in highrise-js-sdk

By default, the 'ready' event is included, ensuring that you receive notifications when the bot is ready and connected to the Highrise server. However, for other events, you need to explicitly include them during the class import.

To include additional events, follow these steps:

  1. Import the Highrise class from the highrise-js-sdk package.
  2. Specify the events you want to receive by passing them as an array to the events parameter during the class import.
  3. Ensure that you import the necessary event handlers or listeners to handle the specific events of interest.

For example:

const { Highrise } = require("highrise-js-sdk");

// Specify the events you want to receive
const eventsOfInterest = ['ready', 'playerJoin', 'playerLeave', 'messages', 'emoteCreate'];

// Create an instance of the Highrise class with the specified events
const bot = new Highrise({ events: eventsOfInterest });

// Continue with the rest of your code and configurations

By including the desired events during the class import, you ensure that the corresponding event handlers are set up and triggered when those specific events occur within the Highrise environment. To learn more about the available events and their descriptions, you can refer to the Highrise-js SDK Documentation. With the updated event handling mechanism, you have greater control over the types of events you receive, allowing you to tailor the behavior and functionality of your bot according to your specific requirements.

🎐 Events

  • ready
// Event emitted when the bot has successfully connected to the chat server.
client.on('ready', (session) => {
  console.log(`Bot is now online in ${session.room_info.room_name}.\nBot ID: ${session.user_id}\nOwner ID: ${session.room_info.owner_id}\nRate Limits: ${session.rate_limits.client}\nConnection ID: ${session.connection_id}\nSDK Version: ${session.sdk_version}`)
});
  • error
// Event emitted when an error occurs within the package.
client.on('error', (error) => {
  console.log("An Error Occured:", error);
})
  • chatMessageCreate
// Event emitted when a chat message is created.
client.on('chatMessageCreate', (user, message) => {
  console.log(`[${user.username}]: ${message}`);
});
  • whisperMessageCreate
// Event emitted when a whisper message is created.
client.on('whisperMessageCreate', (user, message) => {
  console.log(`[${user.username}] (whisper): ${message}`);
});
  • directMessageCreate
// Event emitted when a direct message is created.
client.on('directMessageCreate', (user, data) => {
  // Process the direct message event
  console.log('Direct message received');
  console.log('User ID:', user);
  console.log('Conversation ID:', data.id);
  console.log('Is New:', data.isNew);

  // Perform additional actions or responses based on the message

  // Example: Send a reply
  client.direct.send(data.id, 'Thank you for your message!');
});
  • emoteCreate
// Event emitted when an emote is created.
client.on('emoteCreate', (sender, receiver, emote) => {
  console.log(`${sender.username} sent ${emote} to ${receiver.username}`);
});
  • reactionCreate
// Event emitted when a reaction is created.
client.on('reactionCreate', (sender, receiver, reaction) => {
  console.log(`${sender.username} sent ${reaction} to ${receiver.username}`);
});
  • tipReactionCreate
// Event emitted when a tip reaction is created.
client.on('tipReactionCreate', (sender, receiver, item) => {
  console.log(`Tip reaction from ${sender.username} to ${receiver.username}: ${item.amount} ${item.type}`);
});
  • playerJoin
// Emitted when a player joins the room.
client.on('playerJoin', (user) => {
  console.log(`${user.username}(${user.id}) Joined the room`);
});
  • playerLeave
// Emitted when a player leaves the room.
client.on('playerLeave', (user) => {
  console.log(`${user.username}(${user.id}) Left the room`);
});
  • trackPlayerMovement
// Emitted when a player moves or teleports in the game.
client.on('trackPlayerMovement', (user, position) => {
  if ('x' in position && 'y' in position && 'z' in position && 'facing' in position) {
    console.log(`${user.username} moved to ${position.x}, ${position.y}, ${position.z}, ${position.facing}`);
  } else if ('entity_id' in position && 'anchor_ix' in position) {
    console.log(`${user.username} moved to anchor ${position.entity_id} at index ${position.anchor_ix}`);
  }
});
  • voiceChatCreate
// Emitted when a player change their voice status in the game.
client.on('voiceChatCreate', (users, seconds_left) => {
  console.log(`Seconds Left: ${seconds_left}`)
  console.log('Users:');
  users.forEach(({ user, status }) => {
    console.log('User ID:', user.id);
    console.log('Username:', user.username);
    console.log('Status:', status);
    console.log('---');
  });
});

Note

This package is not an official Highrise package, it's self-made by iHsein (sphinix) and is still in beta.