Skip to content

Commit e6e25f4

Browse files
committed
improve detection of codeblocks for autoformat"
1 parent 271070b commit e6e25f4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/net/javadiscord/javabot/systems/help/AutoCodeFormatter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ private static CodeBlock findCodeblock(@NotNull MessageReceivedEvent event) {
4747
if (closingBracket == -1 || openingBracket == -1) {
4848
return null;
4949
}
50+
if (!msg.substring(openingBracket, closingBracket).contains("\n")) {
51+
return null;
52+
}
5053
int startIndex = msg.lastIndexOf("\n", openingBracket);
5154
int endIndex = msg.indexOf("\n", closingBracket);
5255
if (startIndex == -1) {
@@ -99,7 +102,7 @@ void handleMessageEvent(@Nonnull MessageReceivedEvent event, boolean isFirstMess
99102
}
100103

101104

102-
if (event.getMessage().getContentRaw().contains("```")) {
105+
if (event.getMessage().getContentRaw().contains("`")) {
103106
return; // exit if already contains codeblock
104107
}
105108

0 commit comments

Comments
 (0)