Interface IThreadContainerUnion

All Superinterfaces:
Channel, Comparable<GuildChannel>, Formattable, GuildChannel, IMentionable, IPermissionContainer, ISnowflake, IThreadContainer

public interface IThreadContainerUnion extends IThreadContainer
A union representing all channel types that implement IThreadContainer.
This class extends IThreadContainer and primarily acts as a discovery tool for developers to discover some common interfaces that a IThreadContainer 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.
    • asForumChannel

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

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

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

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

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

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

      @Nonnull GuildMessageChannel asGuildMessageChannel()
      Casts this union to a GuildMessageChannel.
      This works for the following channel types represented by this union:

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

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

      @Nonnull StandardGuildChannel asStandardGuildChannel()
      Casts this union to a StandardGuildChannel.
      This works for the following channel types represented by this union:

      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 works for the following channel types represented by this union:

      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.