Class PermissionOverrideAction

    • Constructor Detail

      • PermissionOverrideAction

        public PermissionOverrideAction​(JDA api,
                                        net.dv8tion.jda.core.requests.Route.CompiledRoute route,
                                        Channel channel,
                                        Member member)
        Creates a new PermissionOverrideAction instance
        Parameters:
        api - The current JDA instance
        route - The Route.CompiledRoute to be used for rate limit handling
        channel - The target Channel for the PermissionOverride
        member - The target Member that will be affected by the PermissionOverride
      • PermissionOverrideAction

        public PermissionOverrideAction​(JDA api,
                                        net.dv8tion.jda.core.requests.Route.CompiledRoute route,
                                        Channel channel,
                                        Role role)
        Creates a new PermissionOverrideAction instance
        Parameters:
        api - The current JDA instance
        route - The Route.CompiledRoute to be used for rate limit handling
        channel - The target Channel for the PermissionOverride
        role - The target Role that will be affected by the PermissionOverride
    • Method Detail

      • setCheck

        public PermissionOverrideAction setCheck​(java.util.function.BooleanSupplier checks)
        Description copied from class: RestAction
        Sets the last-second checks before finally executing the http request in the queue.
        If the provided supplier evaluates to false or throws an exception this will not be finished. When an exception is thrown from the supplier it will be provided to the failure callback.
        Overrides:
        setCheck in class AuditableRestAction<PermissionOverride>
        Parameters:
        checks - The checks to run before executing the request, or null to run no checks
        Returns:
        The current RestAction for chaining convenience
      • getAllow

        public 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

        public java.util.List<Permission> getAllowedPermissions()
        Immutable list of Permissions that would be granted by the PermissionOverride that is created by this action.
        Returns:
        immutable list of granted Permissions
      • getDeny

        public 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

        public java.util.List<Permission> getDeniedPermissions()
        Immutable list of Permissions that would be denied by the PermissionOverride that is created by this action.
        Returns:
        immutable list of denied Permissions
      • getInherited

        public 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

        public java.util.List<Permission> getInheritedPermissions()
        Immutable list of Permissions that would be inherited from other permission holders.
        Permissions returned are not explicitly granted or denied!
        Returns:
        immutable list of inherited Permissions
        See Also:
        getInherited()
      • isMember

        public 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

        public 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

        @CheckReturnValue
        public PermissionOverrideAction setAllow​(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
        See Also:
        EnumSet, setAllow(Permission...)
      • setAllow

        @CheckReturnValue
        public PermissionOverrideAction setAllow​(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
      • setDeny

        @CheckReturnValue
        public PermissionOverrideAction setDeny​(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
        See Also:
        EnumSet, setDeny(Permission...)
      • setDeny

        @CheckReturnValue
        public PermissionOverrideAction setDeny​(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:
        java.lang.IllegalArgumentException - If the any of the specified Permissions is null
      • setPermissions

        @CheckReturnValue
        public PermissionOverrideAction setPermissions​(java.util.Collection<Permission> grantPermissions,
                                                       java.util.Collection<Permission> denyPermissions)
        Combination of setAllow(java.util.Collection) and setDeny(java.util.Collection)
        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
        See Also:
        EnumSet, Permission.getRaw(Collection)