VoiceGateway

An implementation of the Discord Gateway (see gateway-only, not UDP connection in docs) and its lifecycle.

Allows consumers to receive VoiceEvents through events and send Commands through send.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The incoming VoiceEvents of the Gateway. Users should expect kotlinx.coroutines.flow.Flows to be hot and remain open for the entire lifecycle of the Gateway.

Link copied to clipboard
abstract val ping: StateFlow<Duration?>

The Duration between the last Heartbeat and HeartbeatAck.

Link copied to clipboard
abstract val scope: CoroutineScope

Functions

Link copied to clipboard
abstract suspend fun detach()
Link copied to clipboard
inline fun <T : VoiceEvent> VoiceGateway.on(scope: CoroutineScope = this.scope, crossinline consumer: suspend T.() -> Unit): Job

Convenience method that will invoke the consumer on every event T created by VoiceGateway.events.

Link copied to clipboard
abstract suspend fun send(command: Command)

Sends a Command to the gateway, suspending until the message has been sent.

Link copied to clipboard
abstract suspend fun start(configuration: VoiceGatewayConfiguration)

Starts a reconnection voice gateway connection with the given configuration. This function will suspend until the lifecycle of the gateway has ended.

Link copied to clipboard
abstract suspend fun stop()

Close the Gateway and ends the current session, suspending until the underlying websocket is closed.