This event is triggered whenever someone is added to the voice chat, mutes themselves, or unmutes themselves. It has two parameters: one for the users object, which contains the user object with the username and ID, along with their status, indicating whether they are muted or using voice chat.
You can utilize this event to filter players who have muted themselves or are actively using voice chat in the room.
const { Highrise, Events } = require("highrise.sdk");
// Create a new instance of the Highrise class.
const bot = new Highrise({
Events: [
Events.VoiceChat // Listen for voice chat events.
]
});
bot.on("voiceCreate", (users, seconds_left) => {
// Log the voice chat event to the console.
console.log(`[VOICE]: Active users: ${users.length} - Time Left: ${seconds_left} seconds`);
// Filter the users by status.
const mutedUsers = users.filter(user => user.status === "muted");
const voiceUsers = users.filter(user => user.status === "voice");
// Create a list of muted and voice users.
const mutedList = mutedUsers.map(user => user.user.username).join(", ");
const voiceList = voiceUsers.map(user => user.user.username).join(", ");
// Log the muted and voice users to the console.
console.log(`[VOICE]: Muted Users (${mutedUsers.length}): ${mutedList}`);
console.log(`[VOICE]: Voice Users (${voiceUsers.length}): ${voiceList}`);
});
Go Back: Get Methods