class

Discord::VoiceClient

Inherits Reference / Object

Constants

ENCRYPTION_MODES = {"xsalsa20_poly1305_lite", "xsalsa20_poly1305_suffix", "xsalsa20_poly1305"}

Supported encryption modes. Sorted by preference

Log = Discord::Log.for("voice")
OP_HEARTBEAT = 3
OP_HELLO = 8
OP_IDENTIFY = 0
OP_READY = 2
OP_SELECT_PROTOCOL = 1
OP_SESSION_DESCRIPTION = 4
OP_SPEAKING = 5
UDP_PROTOCOL = "udp"

Constructors

new(payload : Discord::Gateway::VoiceServerUpdatePayload, session : Discord::Gateway::Session, user_id : UInt64 | Snowflake)

Creates a new voice client. The payload should be a payload received from Discord as part of a VOICE_SERVER_UPDATE dispatch, received after sending a voice state update (gateway op 4) packet. The session should be the session currently in use by the gateway client on which the aforementioned dispatch was received, and the user_id should be the user ID of the account on which the voice client is created. (It is received as part of the gateway READY dispatch, for example)

Source

Instance methods

close

Closes the VWS connection, in effect disconnecting from voice.

Source
on_ready

Sets the handler that should be run once the voice client has connected successfully.

Source
play_opus(buf : Bytes)

Plays a single opus packet

Source
run

Initiates the connection process and blocks forever afterwards.

Source
send_speaking(speaking : Bool, delay : Int32 = 0)

Sends a packet to indicate to Discord whether or not we are speaking right now

Source