The method player.transport()
is used to transport a player to another room. It requires two parameters: the user ID of the player to transport and the ID of the destination room.
Note: The bot can only transport a player if it is a moderator in the target room and cannot transport them to a room they are already in.
// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", (user, message) => {
if (message === "transport") {
bot.player.transport(user.id, "room-id").catch(e => console.error(e));
}
});
The Highrise.sdk package handles errors directly within the methods themselves. Each method returns a promise, so when using .catch()
, it will log any errors that occur. This feature is useful in scenarios such as when a player leaves the room or when the bot does not have the necessary permissions. Here's an example demonstrating this:
// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", (user, message) => {
if (message === "transport") {
bot.player.transport(user.id, "room-id").catch(e => console.error(e));
}
});
In this example, if the bot is not a moderator in the target room or if the player is already in the specified room, it should log an error and refrain from executing the method.
Go Back: Perform Actions On Player