Interface GuildMessageChannelUnion

All Superinterfaces:
Channel, Comparable<GuildChannel>, Formattable, GuildChannel, GuildMessageChannel, IMentionable, ISnowflake, MessageChannel

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

    • asTextChannel

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

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

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

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

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

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

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

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

      
       //These are the same!
       ThreadChannel channel = union.asThreadChannel();
       ThreadChannel channel2 = (ThreadChannel) union;
       
      You can use Channel.getType().isThread() to validate whether you can call this method in addition to normal instanceof checks: channel instanceof ThreadChannel
      Returns:
      The channel as a ThreadChannel
      Throws:
      IllegalStateException - If the channel represented by this union is not actually a ThreadChannel.
    • 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.
    • asThreadContainer

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

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

      
       //These are the same!
       IThreadContainer channel = union.asThreadContainer();
       IThreadContainer channel2 = (IThreadContainer) union;
       
      You can use channel instanceof IThreadContainer to validate whether you can call this method.
      Returns:
      The channel as a IThreadContainer
      Throws:
      IllegalStateException - If the channel represented by this union is not actually a IThreadContainer.
    • asStandardGuildChannel

      @Nonnull StandardGuildChannel asStandardGuildChannel()
      Casts this union to a StandardGuildChannel.you can call this method

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

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

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

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

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

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

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

      
       //These are the same!
       AudioChannel channel = union.asAudioChannel();
       AudioChannel channel2 = (AudioChannel) union;
       
      You can use channel instanceof AudioChannel to validate whether you can call this method.
      Returns:
      The channel as a AudioChannel
      Throws:
      IllegalStateException - If the channel represented by this union is not actually a AudioChannel.