Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent IndexOutOfBoundsException in interaction replies #4690

Merged
merged 1 commit into from
Dec 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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