Interface RoleAction

    • Method Detail

      • setCheck

        @Nonnull
        RoleAction setCheck​(@Nullable
                            java.util.function.BooleanSupplier checks)
        Description copied from interface: AuditableRestAction
        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.
        Specified by:
        setCheck in interface AuditableRestAction<Role>
        Specified by:
        setCheck in interface RestAction<Role>
        Parameters:
        checks - The checks to run before executing the request, or null to run no checks
        Returns:
        The current RestAction for chaining convenience
        See Also:
        RestAction.getCheck(), RestAction.addCheck(BooleanSupplier)
      • timeout

        @Nonnull
        RoleAction 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<Role>
        Specified by:
        timeout in interface RestAction<Role>
        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)
      • deadline

        @Nonnull
        RoleAction deadline​(long timestamp)
        Description copied from interface: AuditableRestAction
        Similar to RestAction.timeout(long, TimeUnit) but schedules a deadline at which the request has to be completed.
        If the deadline is reached, the request will fail with a TimeoutException.

        This does not mean that the request will immediately timeout when the deadline is reached. JDA will check the deadline right before executing the request or within intervals in a worker thread. This only means the request will timeout if the deadline has passed.

        Example

        
         action.deadline(System.currentTimeMillis() + 10000) // 10 seconds from now
               .queueAfter(20, SECONDS); // request will not be executed within deadline and timeout immediately after 20 seconds
         
        Specified by:
        deadline in interface AuditableRestAction<Role>
        Specified by:
        deadline in interface RestAction<Role>
        Parameters:
        timestamp - Millisecond timestamp at which the request will timeout
        Returns:
        The same RestAction with the applied deadline
        See Also:
        RestAction.timeout(long, TimeUnit), RestAction.setDefaultTimeout(long, TimeUnit)
      • getGuild

        @Nonnull
        Guild getGuild()
        The guild to create the role in
        Returns:
        The guild
      • setName

        @Nonnull
        @CheckReturnValue
        RoleAction setName​(@Nullable
                           java.lang.String name)
        Sets the name for new role (optional)
        Parameters:
        name - The name for the new role, null to use default name
        Returns:
        The current RoleAction, for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided name is longer than 100 characters
      • setHoisted

        @Nonnull
        @CheckReturnValue
        RoleAction setHoisted​(@Nullable
                              java.lang.Boolean hoisted)
        Sets whether or not the new role should be hoisted
        Parameters:
        hoisted - Whether the new role should be hoisted (grouped). Default is false
        Returns:
        The current RoleAction, for chaining convenience
      • setMentionable

        @Nonnull
        @CheckReturnValue
        RoleAction setMentionable​(@Nullable
                                  java.lang.Boolean mentionable)
        Sets whether the new role should be mentionable by members of the parent Guild.
        Parameters:
        mentionable - Whether the new role should be mentionable. Default is false
        Returns:
        The current RoleAction, for chaining convenience
      • setColor

        @Nonnull
        @CheckReturnValue
        default RoleAction setColor​(@Nullable
                                    java.awt.Color color)
        Sets the color which the new role should be displayed with.
        Parameters:
        color - An Color for the new role, null to use default white/black
        Returns:
        The current RoleAction, for chaining convenience
      • setColor

        @Nonnull
        @CheckReturnValue
        RoleAction setColor​(@Nullable
                            java.lang.Integer rgb)
        Sets the Color for the new role. This accepts colors from the range 0x000 to 0xFFFFFF. The provided value will be ranged using rbg & 0xFFFFFF
        Parameters:
        rgb - The color for the new role in integer form, null to use default white/black
        Returns:
        The current RoleAction, for chaining convenience
      • setPermissions

        @Nonnull
        @CheckReturnValue
        default RoleAction setPermissions​(@Nullable
                                          Permission... permissions)
        Sets the Permissions the new Role should have. This will only allow permissions that the current account already holds unless the account is owner or admin of the parent Guild.
        Parameters:
        permissions - The varargs Permissions for the new role
        Returns:
        The current RoleAction, for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not hold one of the specified permissions
        java.lang.IllegalArgumentException - If any of the provided permissions is null
        See Also:
        Permission.getRaw(Permission...)
      • setPermissions

        @Nonnull
        @CheckReturnValue
        default RoleAction setPermissions​(@Nullable
                                          java.util.Collection<Permission> permissions)
        Sets the Permissions the new Role should have. This will only allow permissions that the current account already holds unless the account is owner or admin of the parent Guild.
        Parameters:
        permissions - A Collection of Permissions for the new role
        Returns:
        The current RoleAction, for chaining convenience
        Throws:
        InsufficientPermissionException - If the currently logged in account does not hold one of the specified permissions
        java.lang.IllegalArgumentException - If any of the provided permissions is null
        See Also:
        Permission.getRaw(Collection), EnumSet
      • setIcon

        @Nonnull
        @CheckReturnValue
        RoleAction setIcon​(@Nullable
                           Icon icon)
        Sets the Icon of this Role. This icon will be displayed next to the role's name in the members tab and in chat.
        Parameters:
        icon - The new icon for this Role or null to reset
        Returns:
        RoleManager for chaining convenience
      • setIcon

        @Nonnull
        @CheckReturnValue
        RoleAction setIcon​(@Nullable
                           java.lang.String emoji)
        Sets the Unicode Emoji of this Role instead of a custom image. This emoji will be displayed next to the role's name in the members tab and in chat.
        Parameters:
        emoji - The new Unicode emoji for this Role or null to reset
        Returns:
        RoleManager for chaining convenience