StreamDispatcher
Manages audio playback and streaming for a voice connection. Handles the audio player, voice connection lifecycle, and DSP filters.Constructor
The Discord voice connection
The voice or stage channel being connected to
The guild queue instance
Timeout in milliseconds for connection state changes
Optional audio player instance. If not provided, a new one will be created
Properties
The underlying Discord voice connection
The Discord.js audio player instance
The voice channel the bot is connected to
Currently playing audio resource
Digital Signal Processing filters chain
Reference to the parent guild queue
Timeout duration for voice connection operations
Whether the player is manually paused. Can be set to pause/resume
Current status of the audio player
Current playback volume (0-100)
Current playback time in milliseconds
Audio resampler from the DSP chain
DSP filters from the filter chain
Biquad filter from the DSP chain
Equalizer from the DSP chain
Audio compressor from the DSP chain
Reverb effect from the DSP chain
PCM seeker for track seeking
Methods
createStream
Creates an audio resource from a readable stream with DSP filters.The source audio stream
Stream creation options including:
type: Stream type (e.g.,StreamType.Arbitrary,StreamType.OggOpus)data: Track metadatadisableVolume: Disable volume transformerdisableEqualizer: Disable equalizerdisableBiquad: Disable biquad filterdisableCompressor: Disable compressordisableResampler: Disable resamplerdisableReverb: Disable reverbdisableSeeker: Disable seekereq: Equalizer band configurationbiquadFilter: Biquad filter typedisableFilters: Disable all DSP filtersdefaultFilters: Default PCM filters to applyvolume: Initial volume (0-100)sampleRate: Target sample ratesampleRateFilters: Resampler filter presetcompressor: Compressor parametersreverb: Reverb parametersseeker: Seeker parameters
The created audio resource ready for playback
playStream
Plays an audio resource through the voice connection.The audio resource to play. Defaults to the current audio resource
Returns this dispatcher instance for chaining
pause
Pauses the current playback.If
true, plays 5 packets of silence after pausing to prevent audio glitchesReturns
true if successfully pausedresume
Resumes paused playback.Returns
true if successfully resumedsetVolume
Sets the playback volume.Volume level from 0 to 100
Returns
true if volume was set successfullydisconnect
Disconnects from the voice channel.destroy
Destroys the dispatcher and cleans up all resources.end
Stops the current playback.isPaused
Checks if the player is paused (manually or automatically).Returns
true if pausedisBuffering
Checks if the player is currently buffering.Returns
true if bufferingisPlaying
Checks if the player is currently playing.Returns
true if playingisIdle
Checks if the player is idle.Returns
true if idleisDestroyed
Checks if the voice connection has been destroyed.Returns
true if destroyedisDisconnected
Checks if the voice connection is disconnected.Returns
true if disconnectedisReady
Checks if the voice connection is ready.Returns
true if readyisSignalling
Checks if the voice connection is in signalling state.Returns
true if signallingisConnecting
Checks if the voice connection is connecting.Returns
true if connectingEvents
The StreamDispatcher emits the following events:Emitted when an error occurs in the audio player or voice connection
Emitted for debug messages
Emitted when playback starts
Emitted when playback finishes
Emitted when DSP filters are updated
Emitted when equalizer bands are updated
Emitted when sample rate parameters are updated
Emitted when biquad filters are updated
Emitted when compressor parameters are updated
Emitted when reverb parameters are updated
Emitted when seeker parameters are updated
Emitted when volume is changed
Emitted when the dispatcher is destroyed
Usage Example
Related
- GuildQueueAudioFilters - Audio filters management
- GuildQueue - Guild queue class
- Track - Track class