Party Voice
bot.voice controls the bot's seat in its party's voice room. The shard does the voice connection, Opus encoding and the signed audio Epic requires; your code sends and receives audio over IPC. Party voice needs a shard that runs on Node or Bun. Bots running in the browser (the web app) have no voice, and a category can turn it off with enableVoiceChat: false. Voice calls throw in both cases.
await bot.voice.join();
await bot.voice.play('./sounds/hello.wav');
await bot.voice.leave();Join and leave
| Call | Does |
|---|---|
bot.voice.join() | Joins the voice room of the bot's current party and stays until leave() or until the bot leaves the party. Pass { persistent: false } to leave on its own after 60 seconds without audio. |
bot.voice.leave() | Leaves the room and releases the bot's voice claim. Also stops listening. |
bot.voice.status() | { connected, roomName, persistent, listening }. |
Play audio
bot.voice.play(audio, options) joins first if needed and plays a file path or bytes.
| Option | Meaning |
|---|---|
format | wav (default) or pcm for raw signed 16-bit little-endian, 48kHz, stereo. Paths ending in .pcm or .raw default to pcm. WAV files can use any sample rate and channel count. |
wait | true (default) waits until the audio finished playing; false resolves once it started. |
Plays are queued, never overlapped. Keep clips to a few minutes: the audio travels to the shard over IPC.
await bot.voice.play(pcmBytes, { format: 'pcm', wait: false });Listen to the party
bot.voice.listen() makes the bot receive everyone in the voice room and sends each piece of audio to you as Events.VoiceAudio. It joins voice first if needed and stays, like join(). The voice server only forwards someone's audio to a client that subscribed to them, so a bot that only plays receives nothing.
import { Events } from 'fnlb';
fnlb.on(Events.VoiceAudio, ({ bot, stream, timestamp, format, audio }) => {
// audio is a Uint8Array: one Opus packet, or decoded PCM with { format: 'pcm' }
});
await bot.voice.listen({ format: 'pcm' });
// ...
await bot.voice.stopListening();| Option | Meaning |
|---|---|
format | opus (default): each Opus packet as the server sent it, about 16 per second per speaker (60ms frames). pcm: the same audio decoded on the shard to signed 16-bit little-endian, 48kHz, stereo. |
The server mixes speakers onto a few reserved streams. Packets of one stream play in order by timestamp (a 48kHz clock); to hear the whole party, decode each stream and mix them. A muted speaker sends nothing, so gaps are normal. bot.voice.stopListening() stops the audio and keeps the bot in voice. leave() stops it too.
Who is speaking
While the bot is in voice, Events.VoiceSpeaking reports each speaking change, with or without listen().
fnlb.on(Events.VoiceSpeaking, ({ bot, accountId, speaking }) => {
console.log(accountId, speaking ? 'started' : 'stopped', 'speaking');
});accountId is the speaker's Epic account id. The bot itself is included when it plays audio.
| Event | Payload |
|---|---|
Events.VoiceSpeaking | { bot, accountId, speaking } |
Events.VoiceAudio | { bot, stream, timestamp, format, audio } |