Interface RegularServerChannel

    • Method Detail

      • 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 -1 if the channel is deleted.

        Returns:
        The real position of the channel.
      • updateRawPosition

        default java.util.concurrent.CompletableFuture<java.lang.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 ServerChannelUpdater from createUpdater() 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 use getRawPosition() instead of getPosition()!
        Returns:
        A future to check if the update 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.
      • getOverwrittenPermissions

        <T extends Permissionable & DiscordEntityPermissions 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 java.util.Map<java.lang.Long,​Permissions> getOverwrittenPermissions()
        Gets the overwritten permissions in this channel.
        Returns:
        The overwritten permissions.
      • getOverwrittenUserPermissions

        java.util.Map<java.lang.Long,​Permissions> getOverwrittenUserPermissions()
        Gets the overwritten permissions for users in this channel.
        Returns:
        The overwritten permissions for users.
      • getOverwrittenRolePermissions

        java.util.Map<java.lang.Long,​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.
      • getEffectiveAllowedPermissions

        default java.util.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 has PermissionType.SEND_MESSAGES but not PermissionType.VIEW_CHANNEL cannot send messages, even though he has the PermissionType.SEND_MESSAGES permission.
        Parameters:
        user - The user.
        Returns:
        The effective allowed permissions of a user in this channel.
      • getEffectiveDeniedPermissions

        default java.util.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 has PermissionType.SEND_MESSAGES but not PermissionType.VIEW_CHANNEL cannot send messages, even though he has the PermissionType.SEND_MESSAGES permission.
        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)
      • compareTo

        default int compareTo​(RegularServerChannel channel)

        Implementation note: Only channels from the same server can be compared

        Specified by:
        compareTo in interface java.lang.Comparable<RegularServerChannel>
        Throws:
        java.lang.IllegalArgumentException - If the channels are on different servers.
      • getCurrentCachedInstance

        default java.util.Optional<? extends RegularServerChannel> 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 interface Channel
        Specified by:
        getCurrentCachedInstance in interface ServerChannel
        Specified by:
        getCurrentCachedInstance in interface UpdatableFromCache
        Returns:
        The current cached instance.
      • getLatestInstance

        default java.util.concurrent.CompletableFuture<? extends RegularServerChannel> 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 a NoSuchElementException. If a request to Discord is made, the according remote call exception will be used to complete the CompletableFuture exceptionally.

        Specified by:
        getLatestInstance in interface Channel
        Specified by:
        getLatestInstance in interface ServerChannel
        Specified by:
        getLatestInstance in interface Updatable
        Specified by:
        getLatestInstance in interface UpdatableFromCache
        Returns:
        The current cached instance.