Interface DefaultGuildChannelUnion

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

public interface DefaultGuildChannelUnion extends StandardGuildChannel
A specialized union representing all channel types that can be used for the "default" channel for Guild.getDefaultChannel() or Member.getDefaultChannel().
This is the channel that the Discord client will default to opening when a Guild is opened for the first time when accepting an invite that is not directed at a specific channel.
This class extends StandardGuildChannel and primarily acts as a discovery tool for developers to understand which channels might be returned as default channels.

Not all StandardGuildChannel channels can be used as a default channel!

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.
    • 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.
    • 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.