Skip to content
SinisterRectus edited this page Aug 10, 2018 · 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.

Returns: boolean

getBitrate()

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

Returns: nil

getComplexity()

Returns the complexity of the interal Opus encoder.

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.

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.

Returns: number,

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.

Returns: number,

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.

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.

Returns: nil

setComplexity(complexity)

Parameter Type
complexity number

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

Returns: nil

stopStreap()

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.

Returns: nil

Clone this wiki locally