Interface MemberAction
-
- All Superinterfaces:
RestAction<java.lang.Void>
public interface MemberAction extends RestAction<java.lang.Void>
RestAction
extension specifically designed to allow bots to addUsers
to Guilds.
This requires an OAuth2 Access Token with the scopeguilds.join
to work!
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MemberAction
deadline(long timestamp)
Similar toRestAction.timeout(long, TimeUnit)
but schedules a deadline at which the request has to be completed.java.lang.String
getAccessToken()
The access tokenGuild
getGuild()
TheGuild
to which the user will be added.User
getUser()
The user associated with the idjava.lang.String
getUserId()
The id of the user who will be added by this taskMemberAction
setCheck(java.util.function.BooleanSupplier checks)
Sets the last-second checks before finally executing the http request in the queue.MemberAction
setDeafen(boolean deaf)
Whether the user should be voice deafened in the guild.MemberAction
setMute(boolean mute)
Whether the user should be voice muted in the guild.MemberAction
setNickname(java.lang.String nick)
Sets the nickname of the user for the guild.MemberAction
setRoles(java.util.Collection<Role> roles)
Sets the roles of the user for the guild.MemberAction
setRoles(Role... roles)
Sets the roles of the user for the guild.MemberAction
timeout(long timeout, java.util.concurrent.TimeUnit unit)
Timeout for this RestAction instance.-
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
-
-
-
Method Detail
-
setCheck
@Nonnull MemberAction setCheck(@Nullable java.util.function.BooleanSupplier checks)
Description copied from interface:RestAction
Sets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalse
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 interfaceRestAction<java.lang.Void>
- Parameters:
checks
- The checks to run before executing the request, ornull
to run no checks- Returns:
- The current RestAction for chaining convenience
- See Also:
RestAction.getCheck()
,RestAction.addCheck(BooleanSupplier)
-
timeout
@Nonnull MemberAction timeout(long timeout, @Nonnull java.util.concurrent.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 asdeadline(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 interfaceRestAction<java.lang.Void>
- Parameters:
timeout
- The timeout to useunit
-Unit
for the timeout value- Returns:
- The same RestAction instance with the applied timeout
- See Also:
RestAction.setDefaultTimeout(long, TimeUnit)
-
deadline
@Nonnull MemberAction deadline(long timestamp)
Description copied from interface:RestAction
Similar toRestAction.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 aTimeoutException
.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 interfaceRestAction<java.lang.Void>
- 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)
-
getAccessToken
@Nonnull java.lang.String getAccessToken()
The access token- Returns:
- The access token
-
getUserId
@Nonnull java.lang.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
-
setNickname
@Nonnull @CheckReturnValue MemberAction setNickname(@Nullable java.lang.String nick)
Sets the nickname of the user for the guild.
This will then be visible withMember.getNickname()
.- Parameters:
nick
- The nickname, ornull
- Returns:
- The current MemberAction for chaining
- Throws:
java.lang.IllegalArgumentException
- If the provided nickname is longer than 32 characters
-
setRoles
@Nonnull @CheckReturnValue MemberAction setRoles(@Nullable java.util.Collection<Role> roles)
Sets the roles of the user for the guild.
This will then be visible withMember.getRoles()
.- Parameters:
roles
- The roles, ornull
- Returns:
- The current MemberAction for chaining
- Throws:
java.lang.IllegalArgumentException
- If one of the provided roles is null or not from the same guild
-
setRoles
@Nonnull @CheckReturnValue MemberAction setRoles(@Nullable Role... roles)
Sets the roles of the user for the guild.
This will then be visible withMember.getRoles()
.- Parameters:
roles
- The roles, ornull
- Returns:
- The current MemberAction for chaining
- Throws:
java.lang.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
-
-