Skip to content

Commit

Permalink
handle longer messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitsmt211 committed Oct 27, 2023
1 parent 4518643 commit 9e3f922
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final class TransferQuestionCommand extends BotCommandAdapter
private static final Pattern TITLE_GUESS_COMPACT_REMOVAL_PATTERN = Pattern.compile("\\W");
private static final int TITLE_MIN_LENGTH = 3;
private static final Color EMBED_COLOR = new Color(50, 164, 168);
private static final int INPUT_MAX_LENGTH = 2000;
private static final int INPUT_MAX_LENGTH = Message.MAX_CONTENT_LENGTH;
private static final int INPUT_MIN_LENGTH = 3;
private final Predicate<String> isHelpForumName;
private final List<String> tags;
Expand Down Expand Up @@ -96,7 +96,8 @@ public void onMessageContext(MessageContextInteractionEvent event) {
.setPlaceholder("Contents of the question");

if (!isQuestionTooShort(originalMessage)) {
modalInputBuilder.setValue(originalMessage);
String trimmedMessage = getMessageUptoMaxLimit(originalMessage);
modalInputBuilder.setValue(trimmedMessage);
}

TextInput modalTag = TextInput.create(MODAL_TAG, "Most fitting tag", TextInputStyle.SHORT)
Expand Down Expand Up @@ -254,4 +255,10 @@ private boolean isInvalidForTransfer(MessageContextInteractionEvent event) {
}
return false;
}

private String getMessageUptoMaxLimit(String originalMessage) {
return originalMessage.length() > INPUT_MAX_LENGTH
? originalMessage.substring(0, INPUT_MAX_LENGTH)
: originalMessage;
}
}

0 comments on commit 9e3f922

Please sign in to comment.