Skip to content

Commit

Permalink
Fix message splitting in MessageBuilder#buildAll (#1680)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtrap committed Jun 23, 2021
1 parent 9750cff commit 5a6388a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/net/dv8tion/jda/api/MessageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ public Queue<Message> buildAll(@Nullable SplitPolicy... policy)

LinkedList<Message> messages = new LinkedList<>();

if (builder.length() <= 2000) {
if (builder.length() <= Message.MAX_CONTENT_LENGTH) {
messages.add(this.build());
return messages;
}
Expand All @@ -1287,7 +1287,7 @@ public Queue<Message> buildAll(@Nullable SplitPolicy... policy)
int currentBeginIndex = 0;

messageLoop:
while (currentBeginIndex < builder.length() - 2001)
while (currentBeginIndex < builder.length() - Message.MAX_CONTENT_LENGTH)
{
for (SplitPolicy splitPolicy : policy)
{
Expand All @@ -1302,9 +1302,9 @@ public Queue<Message> buildAll(@Nullable SplitPolicy... policy)
throw new IllegalStateException("Failed to split the messages");
}

if (currentBeginIndex < builder.length() - 1)
if (currentBeginIndex < builder.length())
{
messages.add(build(currentBeginIndex, builder.length() - 1));
messages.add(build(currentBeginIndex, builder.length()));
}

if (this.embeds != null)
Expand Down

0 comments on commit 5a6388a

Please sign in to comment.