class Discord::VoiceClient
- Discord::VoiceClient
- Reference
- Object
Defined in:
discordcr/voice.crConstant Summary
-
ENCRYPTED_MODE =
"xsalsa20_poly1305"
-
The mode that tells Discord we want to send encrypted audio
-
HEARTBEAT_JSON =
{op: OP_HEARTBEAT, d: nil}.to_json
-
The heartbeat is the same every time, so it can be a constant
-
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, logger = Logger.new(STDOUT))
Creates a new voice client.
Instance Method Summary
-
#close(*args, **options)
Closes the VWS connection, in effect disconnecting from voice.
-
#close(*args, **options, &block)
Closes the VWS connection, in effect disconnecting from voice.
-
#on_ready(&ready_handler : -> )
Sets the handler that should be run once the voice client has connected successfully.
-
#play_opus(buf : Bytes)
Plays a single opus packet
-
#run
Initiates the connection process and blocks forever afterwards.
-
#send_speaking(speaking : Bool, delay : Int32 = 0)
Sends a packet to indicate to Discord whether or not we are speaking right now
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)
Instance Method Detail
Closes the VWS connection, in effect disconnecting from voice.
Sets the handler that should be run once the voice client has connected successfully.
Sends a packet to indicate to Discord whether or not we are speaking right now