SharedStream

SharedStream

Represents a collection of VoiceConnections sharing an input stream

Constructor

new SharedStream()

Properties:
Name Type Attributes Description
current Object <nullable>

The current stream

ended Boolean

Whether the stream ended

playing Boolean

Whether the voice connection is playing something

speaking Boolean

Whether someone is speaking

volume Number

The current volume level of the connection

Source:

Extends

  • EventEmitter

Methods

add(connection)

Add a voice connection to the shared stream

Source:
Parameters:
Name Type Description
connection VoiceConnection

The voice connection to add

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

Name Type Attributes Default Description
encoderArgs Array.<String> <optional>

Additional encoder parameters to pass to ffmpeg/avconv (after -i)

format String <optional>

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 <optional>
60

The resource opus frame duration (required for DCA/Ogg)

frameSize Number <optional>
2880

The resource opus frame size

inlineVolume Boolean <optional>
false

Whether to enable on-the-fly volume changing. Note that enabling this leads to increased CPU usage

inputArgs Array.<String> <optional>

Additional input parameters to pass to ffmpeg/avconv (before -i)

sampleRate Number <optional>
48000

The resource audio sampling rate

voiceDataTimeout Number <optional>
2000

Timeout when waiting for voice data (-1 for no timeout)

remove(connection)

Remove a voice connection from the shared stream

Source:
Parameters:
Name Type Description
connection VoiceConnection

The voice connection to remove

setVolume(volume)

Sets the volume of this shared stream if inline volume is enabled

Source:
Parameters:
Name Type Description
volume Number

The volume as a value from 0 (min) to 1 (max)

stopPlaying()

Stop the bot from sending audio

Source:

Events

end

Fired when the shared stream finishes playing a stream

Source:

error

Fired when the shared stream encounters an error

Properties:
Name Type Description
e Error

The error

Source:

start

Fired when the shared stream starts playing a stream

Source: