当前位置: 首页>>代码示例>>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;未经允许,请勿转载。