Skip to content

Voice

lunibee (voice) implements the Discord Voice Gateway protocol, encryption, and audio streaming.

You do not need to pass your bot token to voice connections. The client manages the voice handshake and receives a temporary session token from Discord’s VOICE_SERVER_UPDATE event automatically.

import { VoiceConnection } from "lunibee";
const voice = new VoiceConnection({
guildId: "123456789012345678",
channelId: "987654321098765432",
selfMute: false,
selfDeaf: false,
});
voice.connect();

VoiceConnection manages the connection state machine (disconnected, connecting, connected, destroyed) and provides lifecycle hooks:

voice.on("stateChange", (newState, oldState) => {
console.log(`Voice state changed from ${oldState} to ${newState}`);
});
voice.on("speaking", (flags, ssrc) => {
console.log(`Speaking state changed: ${flags}`);
});
  • Voice Gateway Lifecycle: Fast handshakes, state tracking, and heartbeat scheduling.
  • Audio Packet Encryption: Modern AEAD & XSalsa20 voice transport encryption.
  • Transport Abstraction: Plug-and-play Gateway & UDP transports.