public SelfUpdateAvatarEvent(JDA api, long responseNumber, String oldAvatarId) { super(api, responseNumber, oldAvatarId, api.getSelfUser().getAvatarId(), IDENTIFIER); }
@Override protected RequestBody finalizeData() { boolean isClient = getJDA().getAccountType() == AccountType.CLIENT; Checks.check(!isClient || (currentPassword != null && !currentPassword.isEmpty()), "Provided client account password to be used in auth is null or empty!"); JSONObject body = new JSONObject(); //Required fields. Populate with current values.. body.put("username", getSelfUser().getName()); body.put("avatar", opt(getSelfUser().getAvatarId())); if (shouldUpdate(NAME)) body.put("username", name); if (shouldUpdate(AVATAR)) body.put("avatar", avatar == null ? JSONObject.NULL : avatar.getEncoding()); if (isClient) { //Required fields. Populate with current values. body.put("password", currentPassword); body.put("email", email); if (shouldUpdate(EMAIL)) body.put("email", email); if (shouldUpdate(PASSWORD)) body.put("new_password", password); } reset(); return getRequestBody(body); }
private String buildPayload(SelfUser selfUser) { JSONObject main = new JSONObject(); JSONObject bot = new JSONObject(); bot.put("name", selfUser.getName()); bot.put("avatar", selfUser.getAvatarId()); main.put("bot", bot); JSONArray shards = new JSONArray(); for (JDA shard : avaire.getShardManager().getShards()) { JSONObject shardObj = new JSONObject(); shardObj.put("id", shard.getShardInfo().getShardId()); shardObj.put("latency", shard.getPing()); shardObj.put("users", shard.getUsers().size()); shardObj.put("channels", getTotalChannels(shard)); shardObj.put("guilds", shard.getGuilds().size()); shards.put(shardObj); } main.put("shards", shards); return main.toString(); }