Class MemberAction


  • public class MemberAction
    extends RestAction<java.lang.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:
    Discord OAuth2 Documentation
    • Constructor Detail

      • MemberAction

        public MemberAction​(JDA api,
                            Guild guild,
                            java.lang.String userId,
                            java.lang.String accessToken)
    • 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()
        The Guild 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 with Member.getNickname().
        Parameters:
        nick - The nickname, or null
        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 with Member.getRoles().
        Parameters:
        roles - The roles, or null
        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 with Member.getRoles().
        Parameters:
        roles - The roles, or null
        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