Class AccountManager


  • public class AccountManager
    extends net.dv8tion.jda.core.managers.impl.ManagerBase
    Manager providing functionality to update one or more fields for the logged in account.

    Example

    
     manager.setName("Minn")
            .setAvatar(null)
            .queue();
     manager.reset(AccountManager.NAME | AccountManager.AVATAR)
            .setName("DV8FromTheWorld")
            .setAvatar(icon)
            .queue();
     
    See Also:
    JDA.getSelfUser(), SelfUser.getManager()
    • Constructor Detail

      • AccountManager

        public AccountManager​(SelfUser selfUser)
        Creates a new AccountManager instance
        Parameters:
        selfUser - The SelfUser to manage
    • Method Detail

      • getSelfUser

        public SelfUser getSelfUser()
        The SelfUser that will be modified by this AccountManager.
        This represents the currently logged in account.
        Returns:
        The corresponding SelfUser
      • reset

        @CheckReturnValue
        public AccountManager reset​(long fields)
        Resets the fields specified by the provided bit-flag pattern. You can specify a combination by using a bitwise OR concat of the flag constants.
        Example: manager.reset(AccountManager.NAME | AccountManager.AVATAR);

        Flag Constants:

        Overrides:
        reset in class net.dv8tion.jda.core.managers.impl.ManagerBase
        Parameters:
        fields - Integer value containing the flags to reset.
        Returns:
        AccountManager for chaining convenience
      • reset

        @CheckReturnValue
        public AccountManager reset​(long... fields)
        Resets the fields specified by the provided bit-flag patterns. You can specify a combination by using a bitwise OR concat of the flag constants.
        Example: manager.reset(AccountManager.NAME, AccountManager.AVATAR);

        Flag Constants:

        Overrides:
        reset in class net.dv8tion.jda.core.managers.impl.ManagerBase
        Parameters:
        fields - Integer values containing the flags to reset.
        Returns:
        AccountManager for chaining convenience
      • reset

        @CheckReturnValue
        public AccountManager reset()
        Resets all fields for this manager.
        Returns:
        AccountManager for chaining convenience
      • setName

        @CheckReturnValue
        public AccountManager setName​(java.lang.String name)
        Sets the username for the currently logged in account

        Client-Accounts (AccountType.CLIENT) require the current password to be updated. See setName(String, String)

        Parameters:
        name - The new username
        Returns:
        AccountManager for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided name is:
        • Equal to null
        • Less than 2 or more than 32 characters in length
      • setName

        @CheckReturnValue
        public AccountManager setName​(java.lang.String name,
                                      java.lang.String currentPassword)
        Sets the username for the currently logged in account
        Parameters:
        name - The new username
        currentPassword - The current password for the represented account, this is only required for AccountType.CLIENT
        Returns:
        AccountManager for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If this is action is performed on an account with the type CLIENT and the provided password is null or empty
        If the provided name is:
        • Equal to null
        • Less than 2 or more than 32 characters in length
      • setAvatar

        @CheckReturnValue
        public AccountManager setAvatar​(Icon avatar)
        Sets the avatar for the currently logged in account

        Client-Accounts (AccountType.CLIENT) require the current password to be updated. See #setAvatar(Icon, String)

        Parameters:
        avatar - An Icon instance representing the new Avatar for the current account, null to reset the avatar to the default avatar.
        Returns:
        AccountManager for chaining convenience
      • setAvatar

        @CheckReturnValue
        public AccountManager setAvatar​(Icon avatar,
                                        java.lang.String currentPassword)
        Sets the avatar for the currently logged in account
        Parameters:
        avatar - An Icon instance representing the new Avatar for the current account, null to reset the avatar to the default avatar.
        currentPassword - The current password for the represented account, this is only required for AccountType.CLIENT
        Returns:
        AccountManager for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided currentPassword is null or empty and the currently logged in account is from AccountType.CLIENT
      • setEmail

        @CheckReturnValue
        public AccountManager setEmail​(java.lang.String email,
                                       java.lang.String currentPassword)
        Sets the email for the currently logged in client account.
        Parameters:
        email - The new email
        currentPassword - The valid current password for the represented account
        Returns:
        AccountManager for chaining convenience
        Throws:
        AccountTypeException - If the currently logged in account is not from AccountType.CLIENT
        java.lang.IllegalArgumentException -
        • If the provided currentPassword or the provided email is null or empty
        • If the provided email is not valid.
      • setPassword

        @CheckReturnValue
        public AccountManager setPassword​(java.lang.String newPassword,
                                          java.lang.String currentPassword)
        Sets the password for the currently logged in client account.
        If the new password is equal to the current password this does nothing.
        Parameters:
        newPassword - The new password for the currently logged in account
        currentPassword - The valid current password for the represented account
        Returns:
        AccountManager for chaining convenience
        Throws:
        AccountTypeException - If the currently logged in account is not from AccountType.CLIENT
        java.lang.IllegalArgumentException - If any of the provided passwords are null or empty