Skip to content

Commit 480f9b8

Browse files
committed
chat watch arg replace < > for leading/trailing space
1 parent 8893e44 commit 480f9b8

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/main/java/vc/commands/WatchCommand.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ private Mono<Message> handleChatWatch(final ChatInputInteractionEvent event, fin
7070
String keyword = addOption.getOption("keyword")
7171
.flatMap(ApplicationCommandInteractionOption::getValue)
7272
.map(ApplicationCommandInteractionOptionValue::asString)
73-
.orElse("");
73+
.orElse("")
74+
.replace("< >", " ");
7475
if (keyword.length() < 3 || keyword.length() > 50) {
7576
return error(event, "Keyword must be between 3 and 50 characters");
7677
}
@@ -106,7 +107,8 @@ private Mono<Message> handleChatWatch(final ChatInputInteractionEvent event, fin
106107
String keyword = deleteOption.getOption("keyword")
107108
.flatMap(ApplicationCommandInteractionOption::getValue)
108109
.map(ApplicationCommandInteractionOptionValue::asString)
109-
.orElse("");
110+
.orElse("")
111+
.replace("< >", " ");
110112
if (keyword.length() < 3 || keyword.length() > 50) {
111113
return error(event, "Keyword must be between 3 and 50 characters");
112114
}
@@ -132,7 +134,9 @@ private Mono<Message> handleChatWatch(final ChatInputInteractionEvent event, fin
132134
} else {
133135
for (var watch : watches) {
134136
builder
135-
.append(escape(watch.keyword()));
137+
.append("`")
138+
.append(watch.keyword())
139+
.append("`");
136140
if (watch.caseSensitive()) {
137141
builder.append(" (case-sensitive)");
138142
}

src/main/java/vc/commands/WatchGuildCommand.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ private Mono<Message> handleChatWatch(final ChatInputInteractionEvent event, fin
9292
String keyword = addOption.getOption("keyword")
9393
.flatMap(ApplicationCommandInteractionOption::getValue)
9494
.map(ApplicationCommandInteractionOptionValue::asString)
95-
.orElse("");
95+
.orElse("")
96+
.replace("< >", " ");
9697
if (keyword.length() < 3 || keyword.length() > 50) {
9798
return error(event, "Keyword must be between 3 and 50 characters");
9899
}
@@ -164,7 +165,8 @@ private Mono<Message> handleChatWatch(final ChatInputInteractionEvent event, fin
164165
String keyword = deleteOption.getOption("keyword")
165166
.flatMap(ApplicationCommandInteractionOption::getValue)
166167
.map(ApplicationCommandInteractionOptionValue::asString)
167-
.orElse("");
168+
.orElse("")
169+
.replace("< >", " ");
168170
if (keyword.length() < 3 || keyword.length() > 50) {
169171
return error(event, "Keyword must be between 3 and 50 characters");
170172
}
@@ -194,7 +196,9 @@ private Mono<Message> handleChatWatch(final ChatInputInteractionEvent event, fin
194196
} else {
195197
for (var watch : watches) {
196198
builder
197-
.append(escape(watch.keyword()));
199+
.append("`")
200+
.append(watch.keyword())
201+
.append("`");
198202
if (watch.caseSensitive()) {
199203
builder.append(" (case-sensitive)");
200204
}

0 commit comments

Comments
 (0)