Interface AudioChannelUnion

All Superinterfaces:
AudioChannel, Channel, Comparable<GuildChannel>, Formattable, GuildChannel, ICategorizableChannel, ICopyableChannel, IInviteContainer, IMemberContainer, IMentionable, IPermissionContainer, IPositionableChannel, ISnowflake, StandardGuildChannel

public interface AudioChannelUnion extends AudioChannel
A union representing all channel types that implement AudioChannel.
This class extends AudioChannel and primarily acts as a discovery tool for developers to discover some common interfaces that a AudioChannel could be cast to.
This interface represents the follow concrete channel types:
  • Method Details

    • asVoiceChannel

      @Nonnull VoiceChannel asVoiceChannel()
      Casts this union to a VoiceChannel.
      This method exists for developer discoverability.

      Note: This is effectively equivalent to using the cast operator:

      
       //These are the same!
       VoiceChannel channel = union.asVoiceChannel();
       VoiceChannel channel2 = (VoiceChannel) union;
       
      You can use Channel.getType() to see if the channel is of type ChannelType.VOICE to validate whether you can call this method in addition to normal instanceof checks: channel instanceof VoiceChannel
      Returns:
      The channel as a VoiceChannel
      Throws:
      IllegalStateException - If the channel represented by this union is not actually a VoiceChannel.
    • asStageChannel

      @Nonnull StageChannel asStageChannel()
      Casts this union to a StageChannel.
      This method exists for developer discoverability.

      Note: This is effectively equivalent to using the cast operator:

      
       //These are the same!
       StageChannel channel = union.asStageChannel();
       StageChannel channel2 = (StageChannel) union;
       
      You can use Channel.getType() to see if the channel is of type ChannelType.STAGE to validate whether you can call this method in addition to normal instanceof checks: channel instanceof StageChannel
      Returns:
      The channel as a StageChannel
      Throws:
      IllegalStateException - If the channel represented by this union is not actually a StageChannel.
    • asGuildMessageChannel

      @Nonnull GuildMessageChannel asGuildMessageChannel()
      Casts this union to a GuildMessageChannel.
      This method exists for developer discoverability.

      Note: This is effectively equivalent to using the cast operator:

      
       //These are the same!
       GuildMessageChannel channel = union.asGuildMessageChannel();
       GuildMessageChannel channel2 = (GuildMessageChannel) union;
       
      Returns:
      The channel as a GuildMessageChannel
      Throws:
      IllegalStateException - If the channel represented by this union is not actually a GuildMessageChannel.