Skip to content
SinisterRectus edited this page Nov 16, 2019 · 13 revisions

Represents a connection to a Discord voice server.

Instances of this class should not be constructed by users.

Properties

Name Type Description
channel GuildVoiceChannel/nil The corresponding GuildVoiceChannel for this connection, if one exists.

Methods

close()

Stops the audio stream for this connection, if one is active, disconnects from the voice server, and leaves the corresponding voice channel. Like most Discordia methods, this must be called inside of a coroutine.

This method always makes a WebSocket request.

Returns: boolean


getBitrate()

Returns the bitrate of the interal Opus encoder in bits per second (bps).

This method only operates on data in memory.

Returns: nil


getComplexity()

Returns the complexity of the interal Opus encoder.

This method only operates on data in memory.

Returns: number


pauseStream()

Temporarily pauses the audio stream for this connection, if one is active. Like most Discordia methods, this must be called inside of a coroutine, as it will yield until the stream is actually paused, usually on the next tick.

This method only operates on data in memory.

Returns: nil


playFFmpeg(path, duration)

Parameter Type Optional
path string
duration number

Plays audio over the established connection using an FFmpeg process, assuming FFmpeg is properly configured. If a duration (in milliseconds) is provided, the audio stream will automatically stop after that time has elapsed; otherwise, it will play until the source is exhausted. The returned number is the time elapsed while streaming and the returned string is a message detailing the reason why the stream stopped. For more information about using FFmpeg, see the voice page.

This method only operates on data in memory.

Returns: number, string


playPCM(source, duration)

Parameter Type Optional
source string/function/table/userdata
duration number

Plays PCM data over the established connection. If a duration (in milliseconds) is provided, the audio stream will automatically stop after that time has elapsed; otherwise, it will play until the source is exhausted. The returned number is the time elapsed while streaming and the returned string is a message detailing the reason why the stream stopped. For more information about acceptable sources, see the voice page.

This method only operates on data in memory.

Returns: number, string


resumeStream()

Resumes the audio stream for this connection, if one is active and paused. Like most Discordia methods, this must be called inside of a coroutine, as it will yield until the stream is actually resumed, usually on the next tick.

This method only operates on data in memory.

Returns: nil


setBitrate(bitrate)

Parameter Type
bitrate number

Sets the bitrate of the interal Opus encoder in bits per second (bps). This should be between 8000 and 128000, inclusive.

This method only operates on data in memory.

Returns: nil


setComplexity(complexity)

Parameter Type
complexity number

Sets the complexity of the interal Opus encoder. This should be between 0 and 10, inclusive.

This method only operates on data in memory.

Returns: nil


stopStream()

Irreversibly stops the audio stream for this connection, if one is active. Like most Discordia methods, this must be called inside of a coroutine, as it will yield until the stream is actually stopped, usually on the next tick.

This method only operates on data in memory.

Returns: nil


Clone this wiki locally