Hello everyone,
I’m excited to announce that Highrise JS SDK version 2.2.0 is now available!
In this update, we have made a few changes to the websocket handler and added some additional methods for the bot’s wallet.
Key points of this update:
- Fixed cache issues.
- Added more wallet methods.
- Improved websocket handler.
- Fixed duplicated messages on reconnect.
To update the package, please follow these commands:
npm uninstall highrise-js-sdk
npm install highrise-js-sdk@latest
New wallet methods:
await bot.wallet.fetch();
returns an array of the amount and type of currency.await bot.wallet.get.voice.amount();
returns the amount of voice tokens.await bot.wallet.get.boost.amount();
returns the amount of boost tokens.await bot.wallet.get.gold.amount();
returns the amount of gold the bot has.
Token purchase methods:
await bot.wallet.buy.voice(payment_method);
await bot.wallet.buy.boost(payment_method, amount);
These methods will return a result with the following possible values:
- “success”: Token bought and applied successfully.
- “insufficient_funds”: The bot/user doesn’t have enough funds to afford a token.
- “only_token_bought”: In rare cases, the bot may succeed in buying a token but fail to apply it. In this case, the token remains in the bot/user inventory and will be used next time. No token is lost this way.
Note: When purchasing a boost, the room will be automatically boosted if the result returns success. The same applies to voice tokens. However, please ensure that the user has the necessary permissions, such as Designer and Moderators.
Payment method parameters:
- “bot_wallet_only”: Only attempts to buy a token from the bot’s wallet and fails if there are insufficient resources.
- “bot_wallet_priority”: First attempts to buy a token from the bot’s wallet. If the bot has insufficient resources, it will attempt to buy from the owner afterwards.
- “user_wallet_only”: Only attempts to buy a token from the owner’s wallet and fails if there are insufficient resources.
Note that if the parameter is not set, it will use “bot_wallet_priority” by default.
Error handling:
When handling errors, the bot will not reconnect automatically. You will need to call the error event as follows:
bot.on('error', (error) => {
console.error('Error occurred:', error);
bot.reconnect(token, room);
});
As some of you may know, Highrise has released a new API to fetch other related data such as rooms, users, and posts. We might create another package for that as we are not responsible for any other APIs. Stay tuned as we may release it in the next few days.
Also, please wait for the changelog to be posted on the website. We will update it soon. This information should suffice to explain the new update since we didn’t make many changes.
Thank you all for your support and patience!