public class AccountManagerUpdatable
extends java.lang.Object
updatable
manager that allows
to modify account settings like the username
or the avatar
.
This manager allows to modify multiple fields at once
by getting the AccountFields
for specific
properties and setting or resetting their values; followed by a call of update(String)
!
The AccountManager
implementation
simplifies this process by giving simple setters that return the update
RestAction
To update the Game
or OnlineStatus
for the current session use the Presence
instance of the corresponding JDA instance
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
EMAIL_PATTERN |
Constructor and Description |
---|
AccountManagerUpdatable(SelfUser selfUser)
Creates a new AccountManagerUpdatable instance
|
Modifier and Type | Method and Description |
---|---|
AccountField<Icon> |
getAvatarField()
An
AccountField
for the avatar of the currently logged in account. |
AccountField<java.lang.String> |
getEmailField()
Client Only
|
JDA |
getJDA()
The
JDA instance of this AccountManagerUpdatable |
AccountField<java.lang.String> |
getNameField()
An
AccountField
for the username of the currently logged in account. |
AccountField<java.lang.String> |
getPasswordField()
Client Only
|
SelfUser |
getSelfUser()
The
SelfUser that will be
modified by this AccountManagerUpdatable instance. |
void |
reset()
Resets all
Fields
for this manager instance by calling Field.reset() sequentially |
RestAction<java.lang.Void> |
update()
Creates a new
RestAction instance
that will apply all changes that have been made to this manager instance (one per runtime per JDA instance). |
RestAction<java.lang.Void> |
update(java.lang.String currentPassword)
Creates a new
RestAction instance
that will apply all changes that have been made to this manager instance. |
public JDA getJDA()
JDA
instance of this AccountManagerUpdatablepublic SelfUser getSelfUser()
SelfUser
that will be
modified by this AccountManagerUpdatable instance.
public AccountField<java.lang.String> getNameField()
AccountField
for the username
of the currently logged in account.
To set the value use setValue(String)
on the returned AccountField
instance.
A username must not be null
nor less than 2 characters or more than 32 characters long!
Otherwise Field.setValue(...)
will
throw an IllegalArgumentException
.
AccountField
- Type: String
public AccountField<Icon> getAvatarField()
AccountField
for the avatar
of the currently logged in account.
To set the value use setValue(Icon)
on the returned AccountField
instance.
An Icon
can be retrieved through one of the static Icon.from(...)
methods
Providing null
as value will cause the default avatar
for this account to be used.
Otherwise Field.setValue(...)
will
throw an IllegalArgumentException
.
AccountField
- Type: Icon
public AccountField<java.lang.String> getEmailField()
An AccountField
for the email
of the currently logged in account.
To set the value use setValue(String)
on the returned AccountField
instance.
An email must not be null
and must be valid according to EMAIL_PATTERN
!
Otherwise Field.setValue(...)
will
throw an IllegalArgumentException
.
AccountField
- Type: String
AccountTypeException
- If the currently logged in account is not from AccountType.CLIENT
public AccountField<java.lang.String> getPasswordField()
An AccountField
for the password
of the currently logged in account.
To set the value use setValue(String)
on the returned AccountField
instance.
A password must not be null
or empty and must be in the range of 6-128 characters in length!
Otherwise Field.setValue(...)
will
throw an IllegalArgumentException
.
AccountField
- Type: String
AccountTypeException
- If the currently logged in account is not from AccountType.CLIENT
public void reset()
Fields
for this manager instance by calling Field.reset()
sequentially@CheckReturnValue public RestAction<java.lang.Void> update(java.lang.String currentPassword)
RestAction
instance
that will apply all changes that have been made to this manager instance.
Before applying new changes it is recommended to call reset()
to reset previous changes.
This is automatically called if this method returns successfully.
Possible ErrorResponses
for this
update include the following:
INVALID_PASSWORD
currentPassword
is not a valid passwordcurrentPassword
- Used for accounts from AccountType.CLIENT
,
provide null
if this is not a client-accountRestAction
Fields
have been modified. (EmptyRestAction
)java.lang.IllegalArgumentException
- If the provided password is null or empty and the currently logged in account
is from AccountType.CLIENT
@CheckReturnValue public RestAction<java.lang.Void> update()
RestAction
instance
that will apply all changes that have been made to this manager instance (one per runtime per JDA instance).
Before applying new changes it is recommended to call reset()
to reset previous changes.
This is automatically called if this method returns successfully.
RestAction
- Type: Void
Updates all modified fields or does nothing if none of the Fields
have been modified. (EmptyRestAction
)AccountTypeException
- If the currently logged in account is from AccountType.CLIENT