Skip to content

Commit

Permalink
[Feature/JShell] Fixing from some feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Alathreon committed Feb 20, 2024
1 parent 4dd8176 commit 719cd75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class JShellCommand extends SlashCommandAdapter {
private static final int MIN_MESSAGE_INPUT_LENGTH = 0;
private static final int MAX_MESSAGE_INPUT_LENGTH = TextInput.MAX_VALUE_LENGTH;

private static final String MAX_SNIPPETS_FILE_PREFIX = " // Snippet 1000";
private static final String MAX_SNIPPETS_EMBED_PREFIX = "Snippet 10```java\n```";
private final JShellEval jshellEval;

/**
Expand Down Expand Up @@ -209,7 +211,7 @@ private void sendSnippets(InteractionHook interactionHook, Member member,
private boolean canBeSentAsEmbed(List<String> snippets) {
return snippets.stream().noneMatch(s -> s.length() >= MessageEmbed.VALUE_MAX_LENGTH)
&& snippets.stream()
.mapToInt(s -> (s + "Snippet 10```java\n```").length())
.mapToInt(s -> (s + MAX_SNIPPETS_EMBED_PREFIX).length())
.sum() < MessageEmbed.EMBED_MAX_LENGTH_BOT - 100
&& snippets.size() <= MessageUtils.MAXIMUM_VISIBLE_EMBEDS;
}
Expand All @@ -229,7 +231,7 @@ private void sendSnippetsAsEmbed(InteractionHook interactionHook, Member member,

private boolean canBeSentAsFile(List<String> snippets) {
return snippets.stream()
.mapToInt(s -> (s + " // Snippet 1000").getBytes().length)
.mapToInt(s -> (s + MAX_SNIPPETS_FILE_PREFIX).getBytes().length)
.sum() < Message.MAX_FILE_SIZE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import javax.annotation.Nullable;

import java.awt.*;
import java.awt.Color;
import java.util.List;
import java.util.Optional;

Expand Down

0 comments on commit 719cd75

Please sign in to comment.