/** * Sets the username for the currently logged in account * * <p><b>Client-Accounts ({@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}) require the * current password to be updated. See {@link #setName(String, String)}</b> * * @param name * The new username * * @throws IllegalArgumentException * If the provided name is: * <ul> * <li>Equal to {@code null}</li> * <li>Less than {@code 2} or more than {@code 32} characters in length</li> * </ul> * * @return AccountManager for chaining convenience */ @CheckReturnValue public AccountManager setName(String name) { return setName(name, null); }
public boolean setUserName(String newName) { if (!getUserName().equals(newName)) { getJda().getSelfUser().getManager().setName(newName).complete(); return true; } return false; }
@Override protected void execute(CommandEvent event) { try { String oldname = event.getSelfUser().getName(); event.getSelfUser().getManager().setName(event.getArgs()).complete(false); event.reply(event.getClient().getSuccess()+" Name changed from `"+oldname+"` to `"+event.getArgs()+"`"); } catch(RateLimitedException e) { event.reply(event.getClient().getError()+" Name can only be changed twice per hour!"); } catch(Exception e) { event.reply(event.getClient().getError()+" That name is not valid!"); } } }