Class MemberAction
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<java.lang.Void>
-
- net.dv8tion.jda.core.requests.restaction.MemberAction
-
public class 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!- Since:
- 3.7.0
- See Also:
- Discord OAuth2 Documentation
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.RestAction
RestAction.EmptyRestAction<T>
-
-
Field Summary
-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description MemberAction(JDA api, Guild guild, java.lang.String userId, java.lang.String accessToken)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
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.-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, complete, completeAfter, getJDA, isPassContext, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setCheck, setPassContext, submit, submit, submitAfter, submitAfter
-
-
-
-
Method Detail
-
getAccessToken
@Nonnull public java.lang.String getAccessToken()
The access token- Returns:
- The access token
-
getUserId
@Nonnull public java.lang.String getUserId()
The id of the user who will be added by this task- Returns:
- The id of the user
-
getUser
@Nullable public User getUser()
The user associated with the id- Returns:
- Possibly-null user associated with the id
-
getGuild
@Nonnull public Guild getGuild()
TheGuild
to which the user will be added.- Returns:
- The Guild
-
setNickname
@CheckReturnValue public MemberAction setNickname(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
@CheckReturnValue public MemberAction setRoles(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
@CheckReturnValue public MemberAction setRoles(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
@CheckReturnValue public 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
@CheckReturnValue public 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
-
-