Skip to main content
A VoiceConnection is the bot in a voice channel of a server: what it plays there, and how it leaves. channel.join() gives one; guild.voice is the one of a server.
How to join and play is in Playing in voice.

Properties

Guild
The server of the voice channel.
VoiceChannel
The voice channel the bot is in.
boolean
Whether the bot is still in voice in this server.
boolean
Whether something is playing, paused or not.
boolean
Whether what is playing is paused.

Helpers

toJSON()

What console.log and JSON.stringify show: the server, the channel and what plays, never the session or its keys.

Actions

play()

Plays a file of public/ (asset('music/intro.ogg')), a file sent on Discord (the attachment option of a command) or a link. Opus (.ogg, .webm) is sent as is; anything else is converted with ffmpeg, which must then be installed. Stops what was playing. Resolves when it ends, is stopped, or another play() replaces it. Discord documentation

pause()

Pauses what is playing; resume() goes on from there.

resume()

Goes on with what was paused.

stop()

Stops what is playing: its play() resolves.

leave()

Leaves the voice channel. Discord documentation

Types

AudioSource

What play() takes: a file of public/ (asset('music/intro.ogg')), a file sent on Discord (the attachment option of a command, or one of message.attachments), or a link starting with https://. See Attachment.

JoinOptions

What join() takes.
boolean
Whether the bot is deafened: it hears nothing, which Discord then does not send it. Default: true, since the bot only plays.
boolean
Whether the bot shows as muted. Default: false.

Errors

join() and play() throw with what to do; the error is shown with the line of your code, like any other.
Give the bot Connect in that channel. play() says the same with Speak.
The user limit of the channel is reached. Raise it, or give the bot Move Members.
Discord did not answer. Try again; if it keeps happening, check the permissions of the bot in the channel.
Install ffmpeg on the machine that runs the bot, or convert the file to .ogg Opus.
ffmpeg could not read the file or the link: the end of the message is what ffmpeg said.
A link or a file sent on Discord could not be downloaded: it was deleted, or the link is wrong.
The connection left, or someone disconnected the bot. Join again for a new connection.