Skip to content

Commit

Permalink
Prevent IndexOutOfBoundsException in interaction replies (#4690)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdcfe committed Dec 15, 2021
1 parent ca1cded commit 3db2647
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public InteractionEventImpl(final SlashCommandEvent jdaEvent) {
public void reply(String message) {
message = FormatUtil.stripFormat(message).replace("§", ""); // Don't ask
replyBuffer.add(message);
event.getHook().editOriginal(new MessageBuilder().setContent(Joiner.on('\n').join(replyBuffer).substring(0, Message.MAX_CONTENT_LENGTH)).setAllowedMentions(DiscordUtil.NO_GROUP_MENTIONS).build())
String reply = Joiner.on('\n').join(replyBuffer);
reply = reply.substring(0, Math.min(Message.MAX_CONTENT_LENGTH, reply.length()));
event.getHook().editOriginal(
new MessageBuilder()
.setContent(reply)
.setAllowedMentions(DiscordUtil.NO_GROUP_MENTIONS).build())
.queue(null, error -> logger.log(Level.SEVERE, "Error while editing command interaction response", error));
}

Expand Down

0 comments on commit 3db2647

Please # to comment.