Package org.javacord.api.entity.channel
Interface Channel
-
- All Superinterfaces:
ChannelAttachableListenerManager
,ChannelSpecialization
,DiscordEntity
,Specializable<ChannelSpecialization>
,Updatable
,UpdatableFromCache
- All Known Subinterfaces:
ChannelCategory
,PrivateChannel
,RegularServerChannel
,ServerChannel
,ServerForumChannel
,ServerStageVoiceChannel
,ServerTextChannel
,ServerThreadChannel
,ServerVoiceChannel
,TextChannel
,UnknownRegularServerChannel
,UnknownServerChannel
,VoiceChannel
public interface Channel extends DiscordEntity, UpdatableFromCache, ChannelAttachableListenerManager, ChannelSpecialization
The class represents a channel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Optional<Categorizable>
asCategorizable()
Gets the channel as categorizable.default java.util.Optional<ChannelCategory>
asChannelCategory()
Gets the channel as channel category.default java.util.Optional<PrivateChannel>
asPrivateChannel()
Gets the channel as private channel.default java.util.Optional<RegularServerChannel>
asRegularServerChannel()
Gets the channel as regular server channel.default java.util.Optional<ServerChannel>
asServerChannel()
Gets the channel as server channel.default java.util.Optional<ServerForumChannel>
asServerForumChannel()
Gets the channel as server forum channel.default java.util.Optional<ServerStageVoiceChannel>
asServerStageVoiceChannel()
Gets the channel as server stage voice channel.default java.util.Optional<ServerTextChannel>
asServerTextChannel()
Gets the channel as server text channel.default java.util.Optional<ServerThreadChannel>
asServerThreadChannel()
Gets the channel as server thread channel.default java.util.Optional<ServerVoiceChannel>
asServerVoiceChannel()
Gets the channel as server voice channel.default java.util.Optional<TextChannel>
asTextChannel()
Gets the channel as text channel.default java.util.Optional<VoiceChannel>
asVoiceChannel()
Gets the channel as voice channel.default boolean
canSee(User user)
Checks if the given user can see this channel.default boolean
canYouSee()
Checks if the user of the connected account can see this channel.default java.util.Optional<? extends Channel>
getCurrentCachedInstance()
Gets an updated instance of this entity from the cache.default java.util.concurrent.CompletableFuture<? extends Channel>
getLatestInstance()
Gets an updated instance of this entity from the cache or from Discord directly.ChannelType
getType()
Gets the type of the channel.-
Methods inherited from interface org.javacord.api.listener.channel.ChannelAttachableListenerManager
addChannelAttachableListener, getChannelAttachableListeners, removeChannelAttachableListener, removeListener
-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getApi, getCreationTimestamp, getId, getIdAsString
-
Methods inherited from interface org.javacord.api.util.Specializable
as
-
-
-
-
Method Detail
-
getType
ChannelType getType()
Gets the type of the channel.- Returns:
- The type of the channel.
-
asPrivateChannel
default java.util.Optional<PrivateChannel> asPrivateChannel()
Gets the channel as private channel.- Returns:
- The channel as private channel.
-
asServerChannel
default java.util.Optional<ServerChannel> asServerChannel()
Gets the channel as server channel.- Returns:
- The channel as server channel.
-
asRegularServerChannel
default java.util.Optional<RegularServerChannel> asRegularServerChannel()
Gets the channel as regular server channel.- Returns:
- The channel as server text channel.
-
asChannelCategory
default java.util.Optional<ChannelCategory> asChannelCategory()
Gets the channel as channel category.- Returns:
- The channel as channel category.
-
asCategorizable
default java.util.Optional<Categorizable> asCategorizable()
Gets the channel as categorizable.- Returns:
- The channel as categorizable.
-
asServerTextChannel
default java.util.Optional<ServerTextChannel> asServerTextChannel()
Gets the channel as server text channel.- Returns:
- The channel as server text channel.
-
asServerForumChannel
default java.util.Optional<ServerForumChannel> asServerForumChannel()
Gets the channel as server forum channel.- Returns:
- The channel as server forum channel.
-
asServerVoiceChannel
default java.util.Optional<ServerVoiceChannel> asServerVoiceChannel()
Gets the channel as server voice channel.- Returns:
- The channel as server voice channel.
-
asServerStageVoiceChannel
default java.util.Optional<ServerStageVoiceChannel> asServerStageVoiceChannel()
Gets the channel as server stage voice channel.- Returns:
- The channel as server stage voice channel.
-
asTextChannel
default java.util.Optional<TextChannel> asTextChannel()
Gets the channel as text channel.- Returns:
- The channel as text channel.
-
asVoiceChannel
default java.util.Optional<VoiceChannel> asVoiceChannel()
Gets the channel as voice channel.- Returns:
- The channel as voice channel.
-
asServerThreadChannel
default java.util.Optional<ServerThreadChannel> asServerThreadChannel()
Gets the channel as server thread channel.- Returns:
- The channel as server thread channel.
-
canSee
default boolean canSee(User user)
Checks if the given user can see this channel. In private channels this always returnstrue
if the user is part of the chat.- Parameters:
user
- The user to check.- Returns:
- Whether the given user can see this channel or not.
-
canYouSee
default boolean canYouSee()
Checks if the user of the connected account can see this channel. In private channels this always returnstrue
if the user is part of the chat.- Returns:
- Whether the user of the connected account can see this channel or not.
-
getCurrentCachedInstance
default java.util.Optional<? extends Channel> getCurrentCachedInstance()
Description copied from interface:UpdatableFromCache
Gets an updated instance of this entity from the cache. This is for example necessary if an instance got invalid by a reconnect to Discord which invalidates all existing instances which means they do not get any further updates from Discord applied. Due to that, references to instances should usually not be held for an extended period of time. If they are, this method can be used to retrieve the current instance from the cache, that gets updates from Discord, in case this one was invalidated.This method returns the currently cached entity, or an empty
Optional
if the entity is not cached any longer, for example because it was deleted or the message was thrown out of the cache.- Specified by:
getCurrentCachedInstance
in interfaceUpdatableFromCache
- Returns:
- The current cached instance.
-
getLatestInstance
default java.util.concurrent.CompletableFuture<? extends Channel> getLatestInstance()
Description copied from interface:Updatable
Gets an updated instance of this entity from the cache or from Discord directly. This is for example necessary if an instance got invalid by a reconnect to Discord which invalidates all existing instances which means they do not get any further updates from Discord applied. Due to that, references to instances should usually not be held for an extended period of time. If they are, this method can be used to retrieve the current instance from the cache if present or from Discord directly.This method returns the currently cached entity if present, or request the entity from Discord if it is not cached or not permanently cached. If the entity is a fully cached entity and is not in the cache any longer, for example because it was deleted or the message was thrown out of the cache, the
CompletableFuture
completes exceptionally with aNoSuchElementException
. If a request to Discord is made, the according remote call exception will be used to complete theCompletableFuture
exceptionally.- Specified by:
getLatestInstance
in interfaceUpdatable
- Specified by:
getLatestInstance
in interfaceUpdatableFromCache
- Returns:
- The current cached instance.
-
-