本文整理汇总了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();