本文整理匯總了Java中net.dv8tion.jda.core.managers.AccountManager類的典型用法代碼示例。如果您正苦於以下問題:Java AccountManager類的具體用法?Java AccountManager怎麽用?Java AccountManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AccountManager類屬於net.dv8tion.jda.core.managers包,在下文中一共展示了AccountManager類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setNickname
import net.dv8tion.jda.core.managers.AccountManager; //導入依賴的package包/類
public static final boolean setNickname(String nickname) {
if (nickname == null || nickname.isEmpty()) {
return false;
}
Config.CONFIG.setBotNickname(nickname);
try {
final JDA jda = getJDA();
if (jda != null) {
final SelfUser user = jda.getSelfUser();
if (user != null) {
if (!nickname.equals(user.getName())) {
final AccountManager manager = user.getManager();
if (manager != null) {
manager.setName(nickname).queue();
System.out.println("Changed nickname to \"" + nickname + "\".");
return true;
} else {
System.err.println("Failed to change nickname to \"" + nickname + "\": AccountManager is null!");
}
} else {
//System.err.println("Failed to change nickname to \"" + nickname + "\": Nickname is already set!");
}
} else {
System.err.println("Failed to change nickname to \"" + nickname + "\": SelfUser is null!");
}
} else {
System.err.println("Failed to change nickname to \"" + nickname + "\": JDA is null!");
}
return false;
} catch (Exception ex) {
System.err.println("Failed to change nickname to \"" + nickname + "\"");
//ex.printStackTrace();
return false;
}
}
示例2: getManager
import net.dv8tion.jda.core.managers.AccountManager; //導入依賴的package包/類
@Override
public AccountManager getManager()
{
AccountManager mng = manager;
if (mng == null)
{
synchronized (mngLock)
{
mng = manager;
if (mng == null)
mng = manager = new AccountManager(this);
}
}
return mng;
}
示例3: getManager
import net.dv8tion.jda.core.managers.AccountManager; //導入依賴的package包/類
/**
* The {@link net.dv8tion.jda.core.managers.AccountManager AccountManager}
* for the currently logged in account.
*
* <p>This can be used to atomically set account fields (like avatar/username)
*
* @return An AccountManager instance for the current account
*/
AccountManager getManager();