Constructor
new VoiceConnection()
Properties:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
channelID |
String
|
The ID of the voice connection's current channel |
|||||||||||||||||||||||||||||||||||||||||||||||||||
connecting |
Boolean
|
Whether the voice connection is connecting |
|||||||||||||||||||||||||||||||||||||||||||||||||||
current |
Object
|
<nullable> |
The state of the currently playing stream |
||||||||||||||||||||||||||||||||||||||||||||||||||
| Name | Type | Description | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
The custom options for the current stream |
|||||||||||||||||||||||||||||||||
| Name | Type | Attributes | Description |
|---|---|---|---|
encoderArgs |
Array.<String>
|
<nullable> |
Additional encoder parameters to pass to ffmpeg/avconv (after -i) |
format |
String
|
<nullable> |
The format of the resource. If null, FFmpeg will attempt to guess and play the format. Available options: "dca", "ogg", "webm", "pcm", "opusPackets", null |
frameDuration |
Number
|
<nullable> |
The resource opus frame duration (required for DCA/Ogg) |
frameSize |
Number
|
<nullable> |
The resource opus frame size |
inlineVolume |
Boolean
|
<nullable> |
Whether to enable on-the-fly volume changing. Note that enabling this leads to increased CPU usage |
inputArgs |
Array.<String>
|
<nullable> |
Additional input parameters to pass to ffmpeg/avconv (before -i) |
sampleRate |
Number
|
<nullable> |
The resource audio sampling rate |
voiceDataTimeout |
Number
|
<nullable> |
Timeout when waiting for voice data (-1 for no timeout) |
pausedTimeNumber
How long the current stream has been paused for, in milliseconds
pausedTimestampNumber
The timestamp of the most recent pause
playTimeNumber
How long the current stream has been playing for, in milliseconds
startTimeNumber
The timestamp of the start of the current stream
idString
The ID of the voice connection (guild ID)
pausedBoolean
Whether the voice connection is paused
playingBoolean
Whether the voice connection is playing something
readyBoolean
Whether the voice connection is ready
resumingBoolean
Whether the voice connection is waiting for resuming
volumeNumber
The current volume level of the connection
- Source:
Extends
- EventEmitter
Methods
_sendAudioPacket()
- Deprecated:
- Yes
- Source:
play(resource, optionsopt)
Play an audio or video resource. If playing from a non-opus resource, FFMPEG should be compiled with --enable-libopus for best performance. If playing from HTTPS, FFMPEG must be compiled with --enable-openssl
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
resource |
ReadableStream
|
String
|
The audio or video resource, either a ReadableStream, URL, or file path |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object
|
<optional> |
Music options
|
receive(typeopt) → {VoiceDataStream}
Generate a receive stream for the voice connection.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
type |
String
|
<optional> |
"pcm" |
The desired voice data type, either "opus" or "pcm" |
Returns:
- Type:
-
VoiceDataStream
sendAudioFrame(frame, frameSizeopt)
Send a packet containing an Opus audio frame
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
frame |
Buffer
|
The Opus audio frame |
|
frameSize |
Number
|
<optional> |
The size (in samples) of the Opus audio frame |
sendUDPPacket(packet)
Send a packet through the connection's UDP socket. The packet is dropped if the socket isn't established
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
packet |
Buffer
|
The packet data |
setVolume(volumeopt)
Modify the output volume of the current stream (if inlineVolume is enabled for the current stream)
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
volume |
Number
|
<optional> |
1.0 |
The desired volume. 0.0 is 0%, 1.0 is 100%, 2.0 is 200%, etc. It is not recommended to go above 2.0 |
switchChannel(channelID)
Switch the voice channel the bot is in. The channel to switch to must be in the same guild as the current voice channel
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
channelID |
String
|
The ID of the voice channel |
updateVoiceState(selfMute, selfDeaf)
Update the bot's voice state
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
selfMute |
Boolean
|
Whether the bot muted itself or not (audio receiving is unaffected) |
selfDeaf |
Boolean
|
Whether the bot deafened itself or not (audio sending is unaffected) |
Events
debug
Fired when stuff happens and gives more info
Properties:
| Name | Type | Description |
|---|---|---|
message |
String
|
The debug message |
- Source:
disconnect
Fired when the voice connection disconnects
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
error |
Error
|
<nullable> |
The error, if any |
- Source:
end
Fired when the voice connection finishes playing a stream
- Source:
error
Fired when the voice connection encounters an error. This event should be handled by users
Properties:
| Name | Type | Description |
|---|---|---|
err |
Error
|
The error object |
- Source:
pong
Fired when the voice connection receives a pong
Properties:
| Name | Type | Description |
|---|---|---|
latency |
Number
|
The current latency in milliseconds |
- Source:
speakingStart
Fired when a user begins speaking
Properties:
| Name | Type | Description |
|---|---|---|
userID |
String
|
The ID of the user that began speaking |
- Source:
speakingStop
Fired when a user stops speaking
Properties:
| Name | Type | Description |
|---|---|---|
userID |
String
|
The ID of the user that stopped speaking |
- Source:
start
Fired when the voice connection starts playing a stream
- Source:
userDisconnect
Fired when a user disconnects from the voice server
Properties:
| Name | Type | Description |
|---|---|---|
userID |
String
|
The ID of the user that disconnected |
- Source:
usersConnect
Fired when one or more clients connect to the voice channel
Properties:
| Name | Type | Description |
|---|---|---|
userIDs |
Array.<String>
|
The IDs of the users that connected |
- Source:
warn
Fired to warn of something weird but non-breaking happening
Properties:
| Name | Type | Description |
|---|---|---|
message |
String
|
The warning message |
- Source: