The method player.voice.add()
is used to grant voice permissions to a player in the current room. It requires one parameter: the user ID of the player to whom you want to grant voice permissions.
// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", async (user, message) => {
if (message === "voice add") {
bot.player.voice.add(user.id).then(() => {
console.log(`[VOICE]: Added voice to ${user.username}`);
}).catch(e => { console.error(e) });
}
});
The method player.voice.remove()
is used to revoke voice permissions from a player in the current room.
// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", async (user, message) => {
if (message === "voice remove") {
bot.player.voice.remove(user.id).then(() => {
console.log(`[VOICE]: Removed voice from ${user.username}`);
}).catch(e => { console.error(e) });
}
});
Note: The bot can only perform these actions if it is owned by the room owner or if it has the required permissions to perform the action in the room. If the bot does not have the necessary permissions, it will encounter an error and log it.
In these examples, if there is an error granting or revoking voice permissions, it should log the error and refrain from executing the method.
Go Back: Perform Actions On Player