Interface MemberAction
-
- All Superinterfaces:
RestAction<java.lang.Void>
public interface MemberAction extends RestAction<java.lang.Void>
RestActionextension specifically designed to allow bots to addUsersto Guilds.
This requires an OAuth2 Access Token with the scopeguilds.jointo work!
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MemberActiondeadline(long timestamp)Similar toRestAction.timeout(long, TimeUnit)but schedules a deadline at which the request has to be completed.java.lang.StringgetAccessToken()The access tokenGuildgetGuild()TheGuildto which the user will be added.UsergetUser()The user associated with the idjava.lang.StringgetUserId()The id of the user who will be added by this taskMemberActionsetCheck(java.util.function.BooleanSupplier checks)Sets the last-second checks before finally executing the http request in the queue.MemberActionsetDeafen(boolean deaf)Whether the user should be voice deafened in the guild.MemberActionsetMute(boolean mute)Whether the user should be voice muted in the guild.MemberActionsetNickname(java.lang.String nick)Sets the nickname of the user for the guild.MemberActionsetRoles(java.util.Collection<Role> roles)Sets the roles of the user for the guild.MemberActionsetRoles(Role... roles)Sets the roles of the user for the guild.MemberActiontimeout(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:RestActionSets the last-second checks before finally executing the http request in the queue.
If the provided supplier evaluates tofalseor 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:
setCheckin interfaceRestAction<java.lang.Void>- Parameters:
checks- The checks to run before executing the request, ornullto 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:RestActionTimeout 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:
timeoutin interfaceRestAction<java.lang.Void>- Parameters:
timeout- The timeout to useunit-Unitfor 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:RestActionSimilar 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:
deadlinein 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
-
-