Interface AudioChannel

All Superinterfaces:
CategorizableChannel, Channel, DiscordObject, Entity, GuildChannel, TopLevelGuildChannel
All Known Implementing Classes:
StageChannel, VoiceChannel

public interface AudioChannel extends CategorizableChannel
A Discord audio channel. This can be either a StageChannel or a VoiceChannel. This superclass contains the common audio methods for these two types.
  • Method Details

    • getBitrate

      default int getBitrate()
      Gets the bitrate (in bits) for this audio channel.
      Returns:
      Gets the bitrate (in bits) for this audio channel.
    • getRtcRegion

      default Region.Id getRtcRegion()
      Gets the voice region id for the audio channel.
      Returns:
      The voice region id for the audio channel.
    • getVoiceStates

      default Flux<VoiceState> getVoiceStates()
      Requests to retrieve the voice states of this audio channel.
      Returns:
      A Flux that continually emits the voice states of this audio channel. If an error is received, it is emitted through the Flux.
    • join

      Deprecated.
      use join(AudioChannelJoinSpec) or join() which offer an immutable approach to build specs
      Request to join this audio channel upon subscription. The resulting VoiceConnection will be available to you from the Mono but also through a VoiceConnectionRegistry and can be obtained through GatewayDiscordClient.getVoiceConnectionRegistry(). Additionally, the resulting VoiceConnection can be retrieved from the associated guild through Guild.getVoiceConnection() and through getVoiceConnection().
      Parameters:
      spec - A Consumer that provides a "blank" LegacyVoiceChannelJoinSpec to be operated on.
      Returns:
      A Mono where, upon successful completion, emits a VoiceConnection, indicating a connection to the channel has been established. If an error is received, it is emitted through the Mono.
    • join

      default discord4j.core.spec.AudioChannelJoinMono join()
      Request to join this audio channel upon subscription. Properties specifying how to join this audio channel can be set via the withXxx methods of the returned AudioChannelJoinMono. The resulting VoiceConnection will be available to you from the Mono but also through a VoiceConnectionRegistry and can be obtained through GatewayDiscordClient.getVoiceConnectionRegistry(). Additionally, the resulting VoiceConnection can be retrieved from the associated guild through Guild.getVoiceConnection() and through getVoiceConnection().
      Returns:
      A AudioChannelJoinMono where, upon successful completion, emits a VoiceConnection, indicating a connection to the channel has been established. If an error is received, it is emitted through the AudioChannelJoinMono.
    • join

      default Mono<VoiceConnection> join(discord4j.core.spec.AudioChannelJoinSpec spec)
      Request to join this audio channel upon subscription. The resulting VoiceConnection will be available to you from the Mono but also through a VoiceConnectionRegistry and can be obtained through GatewayDiscordClient.getVoiceConnectionRegistry(). Additionally, the resulting VoiceConnection can be retrieved from the associated guild through Guild.getVoiceConnection() and through getVoiceConnection().
      Parameters:
      spec - an immutable object that specifies how to join this audio channel
      Returns:
      A Mono where, upon successful completion, emits a VoiceConnection, indicating a connection to the channel has been established. If an error is received, it is emitted through the Mono.
    • sendConnectVoiceState

      default Mono<Void> sendConnectVoiceState(boolean selfMute, boolean selfDeaf)
      Sends a join request to the gateway

      This method does not trigger any logic and requires external state handling

      Parameters:
      selfMute - if the client should be mutes
      selfDeaf - if the client should be deaf
      Returns:
      An empty mono which completes when the payload was sent to the gateway
    • sendDisconnectVoiceState

      default Mono<Void> sendDisconnectVoiceState()
      Sends a leave request to the gateway

      This method does not replace VoiceConnection.disconnect() when the channel was joined by using join(AudioChannelJoinSpec)

      Returns:
      An empty mono which completes when the payload was sent to the gateway
    • isMemberConnected

      default Mono<Boolean> isMemberConnected(Snowflake memberId)
      Requests to determine if the member represented by the provided Snowflake is connected to this audio channel.
      Parameters:
      memberId - The ID of the member to check.
      Returns:
      A Mono where, upon successful completion, emits true if the member represented by the provided Snowflake is connected to this audio channel, false otherwise. If an error is received, it is emitted through the Mono.
    • getVoiceConnection

      default Mono<VoiceConnection> getVoiceConnection()
      Returns the current voice connection registered for this audio channel's guild.
      Returns:
      A Mono of VoiceConnection for this audio channel's guild if present, or empty otherwise. The resulting Mono will also complete empty if the registered voice connection is not associated with this audio channel.