/** * Creates a new {@link MessageHistory MessageHistory} object for each call of this method. * <br>MessageHistory is <b>NOT</b> an internal message cache, but rather it queries the Discord servers for previously sent messages. * * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If this is a {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} * and the currently logged in account does not have the permission {@link net.dv8tion.jda.core.Permission#MESSAGE_HISTORY MESSAGE_HISTORY} * * @return A {@link net.dv8tion.jda.core.entities.MessageHistory MessageHistory} related to this channel. */ default MessageHistory getHistory() { return new MessageHistory(this); }
@Override protected void handleResponse(Response response, Request<MessageHistory> request) { if (!response.isOk()) { request.onFailure(response); return; } final MessageHistory result = new MessageHistory(channel); final JSONArray array = response.getArray(); final EntityBuilder builder = api.get().getEntityBuilder(); for (int i = 0; i < array.length(); i++) { try { JSONObject obj = array.getJSONObject(i); result.history.put(obj.getLong("id"), builder.createMessage(obj, channel, false)); } catch (JSONException | NullPointerException e) { LOG.warn("Encountered exception in MessagePagination", e); } } request.onSuccess(result); } }
return; MessageHistory history = new MessageHistory(channel); int toRetrieve = amount; int i = 0;