Package discord4j.voice
Interface VoiceConnection
public interface VoiceConnection
Allows for manipulation of an already-established voice connection.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
States of a voice connection. -
Method Summary
Modifier and TypeMethodDescriptionDisconnects this voice connection, tearing down existing resources associated with it.events()
A sequence ofVoiceGatewayEvent
received from the Voice Gateway session.Return the current channel ID associated with thisVoiceConnection
, if available from caching sources.Return the guild ID tied to thisVoiceConnection
.Return whether this voice connection is currently in theVoiceConnection.State.CONNECTED
state.default Mono<VoiceConnection.State>
Return aMono
that completes when this connection reaches aVoiceConnection.State.CONNECTED
orVoiceConnection.State.DISCONNECTED
state.Instruct a reconnect procedure on this voice connection.reconnect
(Function<ContextView, Throwable> errorCause) Instruct a reconnect procedure on this voice connection, using a customThrowable
as cause.Return a sequence of theVoiceConnection.State
transitions this voice connection receives.
-
Method Details
-
events
Flux<VoiceGatewayEvent> events()A sequence ofVoiceGatewayEvent
received from the Voice Gateway session.- Returns:
- a
Flux
ofVoiceGatewayEvent
-
isConnected
Return whether this voice connection is currently in theVoiceConnection.State.CONNECTED
state.- Returns:
- a
Mono
that, upon subscription, returns whether the current state is CONNECTED
-
onConnectOrDisconnect
Return aMono
that completes when this connection reaches aVoiceConnection.State.CONNECTED
orVoiceConnection.State.DISCONNECTED
state. Only state transitions made after subscription are taken into account.- Returns:
- a
Mono
that signals one of the CONNECTED or DISCONNECTED states
-
stateEvents
Flux<VoiceConnection.State> stateEvents()Return a sequence of theVoiceConnection.State
transitions this voice connection receives.- Returns:
- a
Flux
ofVoiceConnection.State
elements
-
disconnect
Disconnects this voice connection, tearing down existing resources associated with it.- Returns:
- a
Mono
that, upon subscription, disconnects this voice connection. If an error occurrs, it is emitted through theMono
-
getGuildId
Snowflake getGuildId()Return the guild ID tied to thisVoiceConnection
. UnlikegetChannelId()
, this method returns synchronously as voice connections are always bound to a single guild.- Returns:
- the guild ID of this connection
-
getChannelId
Return the current channel ID associated with thisVoiceConnection
, if available from caching sources. May return empty if no information is available.- Returns:
- a
Mono
that, upon subscription, returns the channel ID this connection is currently pointing to, if available
-
reconnect
Instruct a reconnect procedure on this voice connection.- Returns:
- a
Mono
that, upon subscription, attempts to reconnect to the voice gateway, maintaining the same parameters currently associated to this instance
-
reconnect
Instruct a reconnect procedure on this voice connection, using a customThrowable
as cause. Implementations can use this to differentiate between a RESUME action (that does not tear down UDP resources) or a full RECONNECT.- Returns:
- a
Mono
that, upon subscription, attempts to reconnect to the voice gateway, maintaining the same parameters currently associated to this instance
-