Interface PermissionOverrideAction

    • Method Detail

      • timeout

        @Nonnull
        PermissionOverrideAction timeout​(long timeout,
                                         @Nonnull
                                         java.util.concurrent.TimeUnit unit)
        Description copied from interface: AuditableRestAction
        Timeout for this RestAction instance.
        If the request doesn't get executed within the timeout it will fail.

        When a RestAction times out, it will fail with a TimeoutException. This is the same as deadline(System.currentTimeMillis() + unit.toMillis(timeout)).

        Example

        
         action.timeout(10, TimeUnit.SECONDS) // 10 seconds from now
               .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
         
        Specified by:
        timeout in interface AuditableRestAction<PermissionOverride>
        Specified by:
        timeout in interface RestAction<PermissionOverride>
        Parameters:
        timeout - The timeout to use
        unit - Unit for the timeout value
        Returns:
        The same RestAction instance with the applied timeout
        See Also:
        RestAction.setDefaultTimeout(long, TimeUnit)
      • reset

        @Nonnull
        default PermissionOverrideAction reset()
        Shortcut for resetAllow().resetDeny().
        The permission override will be empty after this operation
        Returns:
        The current PermissionOverrideAction for chaining convenience
      • resetAllow

        @Nonnull
        PermissionOverrideAction resetAllow()
        Resets the allowed permissions to the current original value.
        For a new override this will just be 0.
        Returns:
        The current PermissionOverrideAction for chaining convenience
      • resetDeny

        @Nonnull
        PermissionOverrideAction resetDeny()
        Resets the denied permissions to the current original value.
        For a new override this will just be 0.
        Returns:
        The current PermissionOverrideAction for chaining convenience
      • getRole

        @Nullable
        Role getRole()
        The Role for this override
        Returns:
        The role, or null if this is a member override
      • getMember

        @Nullable
        Member getMember()
        The Member for this override
        Returns:
        The member, or null if this is a role override
      • getGuild

        @Nonnull
        default Guild getGuild()
        The Guild for this override
        Returns:
        The guild
      • getAllow

        long getAllow()
        The currently set of allowed permission bits.
        This value represents all granted permissions in the raw bitwise representation.

        Use getAllowedPermissions() to retrieve a List with Permissions for this value

        Returns:
        long value of granted permissions
      • getAllowedPermissions

        @Nonnull
        default java.util.EnumSet<Permission> getAllowedPermissions()
        Set of Permissions that would be granted by the PermissionOverride that is created by this action.
        Changes to the returned set do not affect this entity directly.
        Returns:
        set of granted Permissions
      • getDeny

        long getDeny()
        The currently set of denied permission bits.
        This value represents all denied permissions in the raw bitwise representation.

        Use getDeniedPermissions() to retrieve a List with Permissions for this value

        Returns:
        long value of denied permissions
      • getDeniedPermissions

        @Nonnull
        default java.util.EnumSet<Permission> getDeniedPermissions()
        Set of Permissions that would be denied by the PermissionOverride that is created by this action.
        Changes to the returned set do not affect this entity directly.
        Returns:
        set of denied Permissions
      • getInherited

        long getInherited()
        The currently set of inherited permission bits.
        This value represents all permissions that are not explicitly allowed or denied in their raw bitwise representation.
        Inherited Permissions are permissions that are defined by other rules from maybe other PermissionOverrides or a Role.

        Use getInheritedPermissions() to retrieve a List with Permissions for this value

        Returns:
        long value of inherited permissions
      • getInheritedPermissions

        @Nonnull
        default java.util.EnumSet<Permission> getInheritedPermissions()
        Set of Permissions that would be inherited from other permission holders.
        Permissions returned are not explicitly granted or denied!
        Changes to the returned set do not affect this entity directly.
        Returns:
        set of inherited Permissions
        See Also:
        getInherited()
      • isMember

        boolean isMember()
        Whether this Action will create a PermissionOverride for a Member or not
        Returns:
        True, if this is targeting a Member If this is false it is targeting a Role. (isRole())
      • isRole

        boolean isRole()
        Whether this Action will create a PermissionOverride for a Role or not
        Returns:
        True, if this is targeting a Role. If this is false it is targeting a Member. (isMember())
      • setAllow

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction setAllow​(@Nullable
                                                  java.util.Collection<Permission> permissions)
        Sets the value of explicitly granted permissions using a Collection of Permissions.
        Note: Permissions not marked as isChannel() will have no affect!

        Example: setAllow(EnumSet.of(Permission.MESSAGE_READ))

        Parameters:
        permissions - The Collection of Permissions representing the granted permissions for the new PermissionOverride.
        If the provided value is null the permissions are reset to the default of none
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the any of the specified Permissions is null
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        See Also:
        EnumSet, setAllow(Permission...)
      • setAllow

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction setAllow​(@Nullable
                                                  Permission... permissions)
        Sets the value of explicitly granted permissions using a set of Permissions.
        Note: Permissions not marked as isChannel() will have no affect!
        Parameters:
        permissions - The Permissions representing the granted permissions for the new PermissionOverride.
        If the provided value is null the permissions are reset to the default of none
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the any of the specified Permissions is null
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
      • grant

        @Nonnull
        @CheckReturnValue
        PermissionOverrideAction grant​(long allowBits)
        Grants the specified permissions.
        This does not override already granted permissions.
        Parameters:
        allowBits - The permissions to grant, in addition to already allowed permissions
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
      • grant

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction grant​(@Nonnull
                                               java.util.Collection<Permission> permissions)
        Grants the specified permissions.
        This does not override already granted permissions.
        Parameters:
        permissions - The permissions to grant, in addition to already allowed permissions
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        java.lang.IllegalArgumentException - If any provided argument is null
      • grant

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction grant​(@Nonnull
                                               Permission... permissions)
        Grants the specified permissions.
        This does not override already granted permissions.
        Parameters:
        permissions - The permissions to grant, in addition to already allowed permissions
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        java.lang.IllegalArgumentException - If any provided argument is null
      • setDeny

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction setDeny​(@Nullable
                                                 java.util.Collection<Permission> permissions)
        Sets the value of explicitly denied permissions using a Collection of Permissions.
        Note: Permissions not marked as isChannel() will have no affect!

        Example: setDeny(EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_EXT_EMOJI))

        Parameters:
        permissions - The Collection of Permissions representing the denied permissions for the new PermissionOverride.
        If the provided value is null the permissions are reset to the default of none
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the any of the specified Permissions is null
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        See Also:
        EnumSet, setDeny(Permission...)
      • setDeny

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction setDeny​(@Nullable
                                                 Permission... permissions)
        Sets the value of explicitly denied permissions using a set of Permissions.
        Note: Permissions not marked as isChannel() will have no affect!
        Parameters:
        permissions - The Permissions representing the denied permissions for the new PermissionOverride.
        If the provided value is null the permissions are reset to the default of none
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        java.lang.IllegalArgumentException - If the any of the specified Permissions is null
      • deny

        @Nonnull
        @CheckReturnValue
        PermissionOverrideAction deny​(long denyBits)
        Denies the specified permissions.
        This does not override already denied permissions.
        Parameters:
        denyBits - The permissions to deny, in addition to already denied permissions
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
      • deny

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction deny​(@Nonnull
                                              java.util.Collection<Permission> permissions)
        Denies the specified permissions.
        This does not override already denied permissions.
        Parameters:
        permissions - The permissions to deny, in addition to already denied permissions
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        java.lang.IllegalArgumentException - If any provided argument is null
      • deny

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction deny​(@Nonnull
                                              Permission... permissions)
        Denies the specified permissions.
        This does not override already denied permissions.
        Parameters:
        permissions - The permissions to deny, in addition to already denied permissions
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        java.lang.IllegalArgumentException - If any provided argument is null
      • setPermissions

        @Nonnull
        @CheckReturnValue
        default PermissionOverrideAction setPermissions​(@Nullable
                                                        java.util.Collection<Permission> grantPermissions,
                                                        @Nullable
                                                        java.util.Collection<Permission> denyPermissions)
        Combination of setAllow(java.util.Collection) and setDeny(java.util.Collection)
        First sets the granted permissions and then the denied permissions.
        If a passed collection is null it resets the represented value to 0 - no permission specifics.

        Example: setPermissions(EnumSet.of(Permission.MESSAGE_READ), EnumSet.of(Permission.MESSAGE_WRITE, Permission.MESSAGE_EXT_EMOJI))

        Parameters:
        grantPermissions - A Collection of Permissions representing all explicitly granted Permissions for the PermissionOverride
        denyPermissions - A Collection of Permissions representing all explicitly denied Permissions for the PermissionOverride
        Returns:
        The current PermissionOverrideAction - for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the any of the specified Permissions is null
        InsufficientPermissionException - If the currently logged in account does not have Permission.MANAGE_PERMISSIONS on the channel and tries to set permissions it does not have in the channel
        See Also:
        EnumSet, Permission.getRaw(Collection)