Package net.dv8tion.jda.api.managers
Interface AccountManager
-
- All Superinterfaces:
AuditableRestAction<Void>
,Manager<AccountManager>
,RestAction<Void>
public interface AccountManager extends Manager<AccountManager>
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()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description SelfUser
getSelfUser()
TheSelfUser
that will be modified by this AccountManager.AccountManager
reset(long fields)
Resets the fields specified by the provided bit-flag pattern.AccountManager
reset(long... fields)
Resets the fields specified by the provided bit-flag patterns.default AccountManager
setAvatar(Icon avatar)
Sets the avatar for the currently logged in accountAccountManager
setAvatar(Icon avatar, String currentPassword)
Sets the avatar for the currently logged in accountAccountManager
setEmail(String email, String currentPassword)
Sets the email for the currently logged in client account.default AccountManager
setName(String name)
Sets the username for the currently logged in accountAccountManager
setName(String name, String currentPassword)
Sets the username for the currently logged in accountAccountManager
setPassword(String newPassword, String currentPassword)
Sets the password for the currently logged in client account.-
Methods inherited from interface net.dv8tion.jda.api.requests.restaction.AuditableRestAction
reason
-
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
complete, complete, completeAfter, getJDA, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter
-
-
-
-
Field Detail
-
NAME
static final long NAME
Used to reset the name field- See Also:
- Constant Field Values
-
AVATAR
static final long AVATAR
Used to reset the avatar field- See Also:
- Constant Field Values
-
EMAIL
static final long EMAIL
Used to reset the email field- See Also:
- Constant Field Values
-
PASSWORD
static final long PASSWORD
Used to reset the password field- See Also:
- Constant Field Values
-
-
Method Detail
-
getSelfUser
@Nonnull SelfUser getSelfUser()
TheSelfUser
that will be modified by this AccountManager.
This represents the currently logged in account.- Returns:
- The corresponding SelfUser
-
reset
@Nonnull @CheckReturnValue 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:
- Specified by:
reset
in interfaceManager<AccountManager>
- Parameters:
fields
- Integer value containing the flags to reset.- Returns:
- AccountManager for chaining convenience
-
reset
@Nonnull @CheckReturnValue 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:
- Specified by:
reset
in interfaceManager<AccountManager>
- Parameters:
fields
- Integer values containing the flags to reset.- Returns:
- AccountManager for chaining convenience
-
setName
@Nonnull @CheckReturnValue default AccountManager setName(@Nonnull String name)
Sets the username for the currently logged in accountClient-Accounts (
AccountType.CLIENT
) require the current password to be updated. SeesetName(String, String)
- Parameters:
name
- The new username- Returns:
- AccountManager for chaining convenience
- Throws:
IllegalArgumentException
- If the provided name is:- Equal to
null
- Less than
2
or more than32
characters in length
- Equal to
-
setName
@Nonnull @CheckReturnValue AccountManager setName(@Nonnull String name, @Nullable String currentPassword)
Sets the username for the currently logged in account- Parameters:
name
- The new usernamecurrentPassword
- The current password for the represented account, this is only required forAccountType.CLIENT
- Returns:
- AccountManager for chaining convenience
- Throws:
IllegalArgumentException
- If this is action is performed on an account with the typeCLIENT
and the provided password isnull
or empty
If the provided name is:- Equal to
null
- Less than 2 or more than 32 characters in length
- Equal to
-
setAvatar
@Nonnull @CheckReturnValue default AccountManager setAvatar(@Nullable Icon avatar)
Sets the avatar for the currently logged in accountClient-Accounts (
AccountType.CLIENT
) require the current password to be updated. See#setAvatar(Icon, String)
- Parameters:
avatar
- AnIcon
instance representing the new Avatar for the current account,null
to reset the avatar to the default avatar.- Returns:
- AccountManager for chaining convenience
-
setAvatar
@Nonnull @CheckReturnValue AccountManager setAvatar(@Nullable Icon avatar, @Nullable String currentPassword)
Sets the avatar for the currently logged in account- Parameters:
avatar
- AnIcon
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 forAccountType.CLIENT
- Returns:
- AccountManager for chaining convenience
- Throws:
IllegalArgumentException
- If the providedcurrentPassword
isnull
or empty and the currently logged in account is fromAccountType.CLIENT
-
setEmail
@Nonnull @CheckReturnValue AccountManager setEmail(@Nonnull String email, @Nonnull String currentPassword)
Sets the email for the currently logged in client account.- Parameters:
email
- The new emailcurrentPassword
- The valid current password for the represented account- Returns:
- AccountManager for chaining convenience
- Throws:
AccountTypeException
- If the currently logged in account is not fromAccountType.CLIENT
IllegalArgumentException
-- If the provided
currentPassword
or the providedemail
isnull
or empty - If the provided
email
is not valid.
- If the provided
-
setPassword
@Nonnull @CheckReturnValue AccountManager setPassword(@Nonnull String newPassword, @Nonnull 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 accountcurrentPassword
- The valid current password for the represented account- Returns:
- AccountManager for chaining convenience
- Throws:
AccountTypeException
- If the currently logged in account is not fromAccountType.CLIENT
IllegalArgumentException
- If any of the provided passwords arenull
or empty
-
-