Interface ServerChannel
-
- All Superinterfaces:
Channel,ChannelAttachableListenerManager,ChannelSpecialization,Comparable<ServerChannel>,DiscordEntity,Formattable,Nameable,ServerChannelAttachableListenerManager,Specializable<T>,Updatable<T>,UpdatableFromCache
- All Known Subinterfaces:
ChannelCategory,ServerTextChannel,ServerVoiceChannel
public interface ServerChannel extends Channel, Nameable, ServerChannelAttachableListenerManager, Comparable<ServerChannel>
This class represents a server channel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleancanCreateInstantInvite(User user)Checks if the given user can create an instant invite to this channel.default booleancanYouCreateInstantInvite()Checks if the user of the connected account can create an instant invite to this channel.default intcompareTo(ServerChannel channel)default InviteBuildercreateInviteBuilder()Creates an invite builder for this channel.default ServerChannelUpdatercreateUpdater()Create an updater for this channel.default CompletableFuture<Void>delete()Deletes the channel.CompletableFuture<Void>delete(String reason)Deletes the channel.default Optional<? extends ServerChannel>getCurrentCachedInstance()Gets an updated instance of this entity from the cache.default Collection<PermissionType>getEffectiveAllowedPermissions(User user)Gets the effective allowed permissions of a user in this channel.default Collection<PermissionType>getEffectiveDeniedPermissions(User user)Gets the effective denied permissions of a user in this channel.PermissionsgetEffectiveOverwrittenPermissions(User user)Gets the effective overwritten permissions of a user.default PermissionsgetEffectivePermissions(User user)Gets the effective permissions of a user in this channel.CompletableFuture<Collection<RichInvite>>getInvites()Gets the invites of the server.default CompletableFuture<? extends ServerChannel>getLatestInstance()Gets an updated instance of this entity from the cache or from Discord directly.default Map<Permissionable,Permissions>getOverwrittenPermissions()Gets the overwritten permissions in this channel.<T extends Permissionable & DiscordEntity>
PermissionsgetOverwrittenPermissions(T permissionable)Gets the overwritten permissions of an entity in this channel.Map<Role,Permissions>getOverwrittenRolePermissions()Gets the overwritten permissions for roles in this channel.Map<User,Permissions>getOverwrittenUserPermissions()Gets the overwritten permissions for users in this channel.default intgetPosition()Gets the real position of the channel.intgetRawPosition()Gets the raw position of the channel.ServergetServer()Gets the server of the channel.default booleanhasAnyPermission(User user, PermissionType... type)Checks if the user has any of a given set of permissions.default booleanhasPermission(User user, PermissionType permission)Checks if a user has a given permission.default booleanhasPermissions(User user, PermissionType... type)Checks if the user has a given set of permissions.default CompletableFuture<Void>updateName(String name)Updates the name of the channel.default CompletableFuture<Void>updateRawPosition(int rawPosition)Updates the raw position of the channel.-
Methods inherited from interface org.javacord.api.entity.channel.Channel
asCategorizable, asChannelCategory, asGroupChannel, asPrivateChannel, asServerChannel, asServerTextChannel, asServerVoiceChannel, asTextChannel, asVoiceChannel, canSee, canYouSee, getType
-
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, getCreationTimestamp, getId, getIdAsString
-
Methods inherited from interface org.javacord.api.listener.channel.server.ServerChannelAttachableListenerManager
addServerChannelAttachableListener, addServerChannelChangeNameListener, addServerChannelChangeOverwrittenPermissionsListener, addServerChannelChangePositionListener, addServerChannelDeleteListener, getServerChannelAttachableListeners, getServerChannelChangeNameListeners, getServerChannelChangeOverwrittenPermissionsListeners, getServerChannelChangePositionListeners, getServerChannelDeleteListeners, removeListener, removeServerChannelAttachableListener
-
Methods inherited from interface org.javacord.api.util.Specializable
as
-
-
-
-
Method Detail
-
getServer
Server getServer()
Gets the server of the channel.- Returns:
- The server of the channel.
-
getRawPosition
int getRawPosition()
Gets the raw position of the channel. This is the positions sent from Discord and might not be unique and have gaps. Also every channel type (text, voice and category) has its own position counter.- Returns:
- The raw position of the channel.
-
getPosition
default int getPosition()
Gets the real position of the channel. Returns-1if the channel is deleted.- Returns:
- The real position of the channel.
-
createInviteBuilder
default InviteBuilder createInviteBuilder()
Creates an invite builder for this channel.- Returns:
- An invite builder for this channel.
-
getInvites
CompletableFuture<Collection<RichInvite>> getInvites()
Gets the invites of the server.- Returns:
- The invites of the server.
-
createUpdater
default ServerChannelUpdater createUpdater()
Create an updater for this channel.- Returns:
- An updater for this channel.
-
updateName
default CompletableFuture<Void> updateName(String name)
Updates the name of the channel.If you want to update several settings at once, it's recommended to use the
ServerChannelUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
name- The new name of the channel.- Returns:
- A future to check if the update was successful.
-
updateRawPosition
default CompletableFuture<Void> updateRawPosition(int rawPosition)
Updates the raw position of the channel.If you want to update several settings at once, it's recommended to use the
ServerChannelUpdaterfromcreateUpdater()which provides a better performance!- Parameters:
rawPosition- The new position of the channel. If you want to update the position based on other channels, make sure to usegetRawPosition()instead ofgetPosition()!- Returns:
- A future to check if the update was successful.
-
getOverwrittenPermissions
<T extends Permissionable & DiscordEntity> Permissions getOverwrittenPermissions(T permissionable)
Gets the overwritten permissions of an entity in this channel.- Type Parameters:
T- The type of permissionable discord entity.- Parameters:
permissionable- The permissionable entity.- Returns:
- The overwritten permissions of an entity.
-
getOverwrittenPermissions
default Map<Permissionable,Permissions> getOverwrittenPermissions()
Gets the overwritten permissions in this channel.- Returns:
- The overwritten permissions.
-
getOverwrittenUserPermissions
Map<User,Permissions> getOverwrittenUserPermissions()
Gets the overwritten permissions for users in this channel.- Returns:
- The overwritten permissions for users.
-
getOverwrittenRolePermissions
Map<Role,Permissions> getOverwrittenRolePermissions()
Gets the overwritten permissions for roles in this channel.- Returns:
- The overwritten permissions for roles.
-
getEffectiveOverwrittenPermissions
Permissions getEffectiveOverwrittenPermissions(User user)
Gets the effective overwritten permissions of a user. This method also takes into account the roles of the user. It doesn't take into account the "global" permissions!- Parameters:
user- The user.- Returns:
- The effective overwritten permissions of the user.
-
getEffectivePermissions
default Permissions getEffectivePermissions(User user)
Gets the effective permissions of a user in this channel. The returned permission object will only havePermissionState.ALLOWEDandPermissionState.DENIEDstates! It takes into account global permissions and the effective overwritten permissions of a user. Remember, that some permissions affect others! E.g. a user who hasPermissionType.SEND_MESSAGESbut notPermissionType.READ_MESSAGEScannot send messages, even though he has thePermissionType.SEND_MESSAGESpermission.- Parameters:
user- The user.- Returns:
- The effective permissions of the user in this channel.
-
getEffectiveAllowedPermissions
default Collection<PermissionType> getEffectiveAllowedPermissions(User user)
Gets the effective allowed permissions of a user in this channel. It takes into account global permissions and the effective overwritten permissions of a user. Remember, that some permissions affect others! E.g. a user who hasPermissionType.SEND_MESSAGESbut notPermissionType.READ_MESSAGEScannot send messages, even though he has thePermissionType.SEND_MESSAGESpermission.- Parameters:
user- The user.- Returns:
- The effective allowed permissions of a user in this channel.
-
getEffectiveDeniedPermissions
default Collection<PermissionType> getEffectiveDeniedPermissions(User user)
Gets the effective denied permissions of a user in this channel. It takes into account global permissions and the effective overwritten permissions of a user. Remember, that some permissions affect others! E.g. a user who hasPermissionType.SEND_MESSAGESbut notPermissionType.READ_MESSAGEScannot send messages, even though he has thePermissionType.SEND_MESSAGESpermission.- Parameters:
user- The user.- Returns:
- The effective denied permissions of a user in this channel.
-
hasPermissions
default boolean hasPermissions(User user, PermissionType... type)
Checks if the user has a given set of permissions.- Parameters:
user- The user to check.type- The permission type(s) to check.- Returns:
- Whether the user has all given permissions or not.
- See Also:
getEffectiveAllowedPermissions(User)
-
hasAnyPermission
default boolean hasAnyPermission(User user, PermissionType... type)
Checks if the user has any of a given set of permissions.- Parameters:
user- The user to check.type- The permission type(s) to check.- Returns:
- Whether the user has any of the given permissions or not.
- See Also:
getEffectiveAllowedPermissions(User)
-
hasPermission
default boolean hasPermission(User user, PermissionType permission)
Checks if a user has a given permission. Remember, that some permissions affect others! E.g. a user who hasPermissionType.SEND_MESSAGESbut notPermissionType.READ_MESSAGEScannot send messages, even though he has thePermissionType.SEND_MESSAGESpermission.- Parameters:
user- The user.permission- The permission to check.- Returns:
- Whether the user has the permission or not.
-
delete
default CompletableFuture<Void> delete()
Deletes the channel.- Returns:
- A future to tell us if the deletion was successful.
-
delete
CompletableFuture<Void> delete(String reason)
Deletes the channel.- Parameters:
reason- The audit log reason for the deletion.- Returns:
- A future to tell us if the deletion was successful.
-
canCreateInstantInvite
default boolean canCreateInstantInvite(User user)
Checks if the given user can create an instant invite to this channel.- Parameters:
user- The user to check.- Returns:
- Whether the given user can create an instant invite or not.
-
canYouCreateInstantInvite
default boolean canYouCreateInstantInvite()
Checks if the user of the connected account can create an instant invite to this channel.- Returns:
- Whether the user of the connected account can create an instant invite or not.
-
getCurrentCachedInstance
default Optional<? extends ServerChannel> getCurrentCachedInstance()
Description copied from interface:UpdatableFromCacheGets 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
Optionalif the entity is not cached any longer, for example because it was deleted or the message was thrown out of the cache.- Specified by:
getCurrentCachedInstancein interfaceChannel- Specified by:
getCurrentCachedInstancein interfaceUpdatableFromCache- Returns:
- The current cached instance.
-
getLatestInstance
default CompletableFuture<? extends ServerChannel> getLatestInstance()
Description copied from interface:UpdatableGets 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
CompletableFuturecompletes exceptionally with aNoSuchElementException. If a request to Discord is made, the according remote call exception will be used to complete theCompletableFutureexceptionally.- Specified by:
getLatestInstancein interfaceChannel- Specified by:
getLatestInstancein interfaceUpdatable<T extends DiscordEntity>- Specified by:
getLatestInstancein interfaceUpdatableFromCache- Returns:
- The current cached instance.
-
compareTo
default int compareTo(ServerChannel channel)
Implementation note: Only channels from the same server can be compared
- Specified by:
compareToin interfaceComparable<ServerChannel>- Throws:
IllegalArgumentException- If the channels are on different servers.
-
-