當前位置: 首頁>>代碼示例>>Java>>正文


Java AvatarUtil類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:DV8FromTheWorld,項目名稱:JDA-Client,代碼行數:46,代碼來源:ClientAccountManager.java

示例2: setAvatar

import net.dv8tion.jda.utils.AvatarUtil; //導入依賴的package包/類
@Override
public ClientAccountManager setAvatar(AvatarUtil.Avatar avatar)
{
    return (ClientAccountManager) super.setAvatar(avatar);
}
 
開發者ID:DV8FromTheWorld,項目名稱:JDA-Client,代碼行數:6,代碼來源:ClientAccountManager.java


注:本文中的net.dv8tion.jda.utils.AvatarUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。