Interface MessageChannelUnion
- All Superinterfaces:
Channel
,Formattable
,IMentionable
,ISnowflake
,MessageChannel
A union representing all channel types that implement
This class extends
This interface represents the follow concrete channel types:
MessageChannel
.
This class extends
MessageChannel
and primarily acts as a discovery tool for
developers to discover some common interfaces that a MessageChannel
could be cast to.
This interface represents the follow concrete channel types:
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.entities.channel.Channel
MAX_NAME_LENGTH
-
Method Summary
Modifier and TypeMethodDescriptionCasts this union to aAudioChannel
.Casts this union to aGuildMessageChannel
.Casts this union to aNewsChannel
.Casts this union to aPrivateChannel
.Casts this union to aStageChannel
.Casts this union to aTextChannel
.Casts this union to aThreadChannel
.Casts this union to aIThreadContainer
.Casts this union to aVoiceChannel
.Methods inherited from interface net.dv8tion.jda.api.entities.channel.Channel
delete, formatTo, getAsMention, getFlags, getJDA, getName, getType
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
Methods inherited from interface net.dv8tion.jda.api.entities.channel.middleman.MessageChannel
addReactionById, addReactionById, canTalk, deleteMessageById, deleteMessageById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageFormatById, editMessageFormatById, endPollById, endPollById, getHistory, getHistoryAfter, getHistoryAfter, getHistoryAfter, getHistoryAround, getHistoryAround, getHistoryAround, getHistoryBefore, getHistoryBefore, getHistoryBefore, getHistoryFromBeginning, getIterableHistory, getLatestMessageId, getLatestMessageIdLong, pinMessageById, pinMessageById, purgeMessages, purgeMessages, purgeMessagesById, purgeMessagesById, purgeMessagesById, removeReactionById, removeReactionById, retrieveMessageById, retrieveMessageById, retrievePinnedMessages, retrievePollVotersById, retrievePollVotersById, retrieveReactionUsersById, retrieveReactionUsersById, sendFiles, sendFiles, sendMessage, sendMessage, sendMessageComponents, sendMessageComponents, sendMessageEmbeds, sendMessageEmbeds, sendMessageFormat, sendMessagePoll, sendTyping, unpinMessageById, unpinMessageById
-
Method Details
-
asPrivateChannel
Casts this union to aPrivateChannel
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! PrivateChannel channel = union.asPrivateChannel(); PrivateChannel channel2 = (PrivateChannel) union;
Channel.getType()
to see if the channel is of typeChannelType.PRIVATE
to validate whether you can call this method in addition to normal instanceof checks:channel instanceof PrivateChannel
- Returns:
- The channel as a
PrivateChannel
- Throws:
IllegalStateException
- If the channel represented by this union is not actually aPrivateChannel
.
-
asTextChannel
Casts this union to aTextChannel
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! TextChannel channel = union.asTextChannel(); TextChannel channel2 = (TextChannel) union;
Channel.getType()
to see if the channel is of typeChannelType.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 aTextChannel
.
-
asNewsChannel
Casts this union to aNewsChannel
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! NewsChannel channel = union.asNewsChannel(); NewsChannel channel2 = (NewsChannel) union;
Channel.getType()
to see if the channel is of typeChannelType.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 aNewsChannel
.
-
asThreadChannel
Casts this union to aThreadChannel
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! ThreadChannel channel = union.asThreadChannel(); ThreadChannel channel2 = (ThreadChannel) union;
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 aThreadChannel
.
-
asVoiceChannel
Casts this union to aVoiceChannel
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! VoiceChannel channel = union.asVoiceChannel(); VoiceChannel channel2 = (VoiceChannel) union;
Channel.getType()
to see if the channel is of typeChannelType.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 aVoiceChannel
.
-
asStageChannel
Casts this union to aStageChannel
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! StageChannel channel = union.asStageChannel(); StageChannel channel2 = (StageChannel) union;
Channel.getType()
to see if the channel is of typeChannelType.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 aStageChannel
.
-
asThreadContainer
Casts this union to aIThreadContainer
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! IThreadContainer channel = union.asThreadContainer(); IThreadContainer channel2 = (IThreadContainer) union;
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 aIThreadContainer
.
-
asGuildMessageChannel
Casts this union to aGuildMessageChannel
.
This works for the following channel types represented by this union:Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! GuildMessageChannel channel = union.asGuildMessageChannel(); GuildMessageChannel channel2 = (GuildMessageChannel) union;
Channel.getType()
.isGuild()
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 aGuildMessageChannel
.
-
asAudioChannel
Casts this union to aAudioChannel
. This method exists for developer discoverability.Note: This is effectively equivalent to using the cast operator:
You can use//These are the same! AudioChannel channel = union.asAudioChannel(); AudioChannel channel2 = (AudioChannel) union;
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 aAudioChannel
.
-