本文整理汇总了Java中net.dv8tion.jda.utils.AvatarUtil类的典型用法代码示例。如果您正苦于以下问题:Java AvatarUtil类的具体用法?Java AvatarUtil怎么用?Java AvatarUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AvatarUtil类属于net.dv8tion.jda.utils包,在下文中一共展示了AvatarUtil类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import net.dv8tion.jda.utils.AvatarUtil; //导入依赖的package包/类
/**
* Updates the profile of the connected account, sends the changed data to the Discord server.
* <br>
* The provided password is used to authenticate and apply the updates to the profile.
*
* @param password
* The password used to login to currently logged in account.
*/
public void update(String password)
{
try
{
JSONObject object = new JSONObject();
object.put("email", email == null ? ((JDAClient) api).getSelfInfo().getEmail() : email);
object.put("password", password);
object.put("username", username == null ? api.getSelfInfo().getUsername() : username);
object.put("avatar", avatar == null
? api.getSelfInfo().getAvatarId()
: (avatar == AvatarUtil.DELETE_AVATAR
? JSONObject.NULL
: avatar.getEncoded()));
if (newPassword != null)
{
object.put("new_password", newPassword);
}
Requester.Response response = api.getRequester().patch(ClientRequester.DISCORD_API_PREFIX + "users/@me", object);
if (!response.isOk() || !response.getObject().has("token"))
{
throw new Exception("Something went wrong while changing the account settings.");
}
api.setAuthToken(response.getObject().getString("token"));
this.avatar = null;
this.email = null;
this.newPassword = null;
this.username = null;
}
catch (Exception e)
{
JDAImpl.LOG.log(e);
}
}
示例2: setAvatar
import net.dv8tion.jda.utils.AvatarUtil; //导入依赖的package包/类
@Override
public ClientAccountManager setAvatar(AvatarUtil.Avatar avatar)
{
return (ClientAccountManager) super.setAvatar(avatar);
}