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 SelfUsergetSelfUser()TheSelfUserthat will be modified by this AccountManager.AccountManagerreset(long fields)Resets the fields specified by the provided bit-flag pattern.AccountManagerreset(long... fields)Resets the fields specified by the provided bit-flag patterns.default AccountManagersetAvatar(Icon avatar)Sets the avatar for the currently logged in accountAccountManagersetAvatar(Icon avatar, String currentPassword)Sets the avatar for the currently logged in accountAccountManagersetEmail(String email, String currentPassword)Sets the email for the currently logged in client account.default AccountManagersetName(String name)Sets the username for the currently logged in accountAccountManagersetName(String name, String currentPassword)Sets the username for the currently logged in accountAccountManagersetPassword(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()
TheSelfUserthat 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:
resetin 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:
resetin 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
2or more than32characters 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 typeCLIENTand the provided password isnullor 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- AnIconinstance representing the new Avatar for the current account,nullto 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- AnIconinstance representing the new Avatar for the current account,nullto 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 providedcurrentPasswordisnullor 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.CLIENTIllegalArgumentException-- If the provided
currentPasswordor the providedemailisnullor empty - If the provided
emailis 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.CLIENTIllegalArgumentException- If any of the provided passwords arenullor empty
-
-