Interface MemberAction

All Superinterfaces:
RestAction<Void>

public interface MemberAction extends RestAction<Void>
RestAction extension specifically designed to allow bots to add Users to Guilds.
This requires an OAuth2 Access Token with the scope guilds.join to work!
Since:
3.7.0
See Also:
  • Method Details

    • setCheck

      Description copied from interface: 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.
      Specified by:
      setCheck in interface RestAction<Void>
      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:
    • timeout

      @Nonnull MemberAction timeout(long timeout, @Nonnull TimeUnit unit)
      Description copied from interface: RestAction
      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 RestAction<Void>
      Parameters:
      timeout - The timeout to use
      unit - Unit for the timeout value
      Returns:
      The same RestAction instance with the applied timeout
      See Also:
    • deadline

      @Nonnull MemberAction deadline(long timestamp)
      Description copied from interface: RestAction
      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 RestAction<Void>
      Parameters:
      timestamp - Millisecond timestamp at which the request will timeout
      Returns:
      The same RestAction with the applied deadline
      See Also:
    • getAccessToken

      @Nonnull String getAccessToken()
      The access token
      Returns:
      The access token
    • getUserId

      @Nonnull String getUserId()
      The id of the user who will be added by this task
      Returns:
      The id of the user
    • getUser

      @Nullable User getUser()
      The user associated with the id
      Returns:
      Possibly-null user associated with the id
    • getGuild

      @Nonnull Guild getGuild()
      The Guild to which the user will be added.
      Returns:
      The Guild
    • setNickname

      Sets the nickname of the user for the guild.
      This will then be visible with Member.getNickname().
      Parameters:
      nick - The nickname, or null
      Returns:
      The current MemberAction for chaining
      Throws:
      IllegalArgumentException - If the provided nickname is longer than 32 characters
    • setRoles

      Sets the roles of the user for the guild.
      This will then be visible with Member.getRoles().
      Parameters:
      roles - The roles, or null
      Returns:
      The current MemberAction for chaining
      Throws:
      IllegalArgumentException - If one of the provided roles is null or not from the same guild
    • setRoles

      Sets the roles of the user for the guild.
      This will then be visible with Member.getRoles().
      Parameters:
      roles - The roles, or null
      Returns:
      The current MemberAction for chaining
      Throws:
      IllegalArgumentException - If one of the provided roles is null or not from the same guild
    • setMute

      @Nonnull @CheckReturnValue MemberAction setMute(boolean mute)
      Whether the user should be voice muted in the guild.
      Default: false
      Parameters:
      mute - Whether the user should be voice muted in the guild.
      Returns:
      The current MemberAction for chaining
    • setDeafen

      @Nonnull @CheckReturnValue MemberAction setDeafen(boolean deaf)
      Whether the user should be voice deafened in the guild.
      Default: false
      Parameters:
      deaf - Whether the user should be voice deafened in the guild.
      Returns:
      The current MemberAction for chaining