Auto-leave
new Raya({ nodes, connector, playerDefaults: { queueEndTimeout: 120_000, // leave 2 minutes after the queue ends emptyChannelTimeout: 60_000, // leave 1 minute after the last listener leaves pauseOnEmpty: true, // pause while nobody is listening },});All three are off by default.
Queue end
Section titled “Queue end”When the queue ends (and autoplay found nothing), the player is destroyed after queueEndTimeout ms. Playing anything before then cancels it. The destroy reason is 'queueEnd'.
Empty channel
Section titled “Empty channel”Raya reads raw gateway events to know who is in each voice channel. No Discord library cache is needed.
- When the last human leaves,
voiceChannelEmptyfires. WithpauseOnEmpty, playback pauses. - When someone comes back,
voiceChannelFilledfires, and if Raya paused it, playback resumes. - If the channel is still empty after
emptyChannelTimeoutms, the player is destroyed with reason'channelEmpty'.
raya.on('voiceChannelEmpty', (player) => notify(player, 'Paused until someone joins'));raya.on('playerDestroy', (player, reason) => { if (reason === 'channelEmpty') notify(player, 'Left because everyone left');});Bots don’t count as listeners.
Other reasons a player is destroyed
Section titled “Other reasons a player is destroyed”| Reason | When |
|---|---|
'voiceDisconnected' |
The bot was kicked or disconnected from voice |
'channelDeleted' |
The voice channel was deleted |
'guildDeleted' |
The bot left or was removed from the guild |
'manual' |
You called destroy() |
Set playerDefaults.destroyOnVoiceDisconnect: false to keep players after a kick.