class Discord::VoiceClient

Defined in:

discordcr/voice.cr

Constant Summary

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

Instance Method Summary

Constructor Detail

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)


[View source]

Instance Method Detail

def close #

Closes the VWS connection, in effect disconnecting from voice.


[View source]
def on_ready(&ready_handler : -> ) #

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


[View source]
def play_opus(buf : Bytes) #

Plays a single opus packet


[View source]
def run #

Initiates the connection process and blocks forever afterwards.


[View source]
def send_speaking(speaking : Bool, delay : Int32 = 0) #

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


[View source]