Skip to content

Commit 9256f1c

Browse files
committed
try catch around resolver execution
1 parent 1aab307 commit 9256f1c

14 files changed

+52
-52
lines changed

src/main/java/vc/commands/ChatSearchCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Mono<Message> handle(final ChatInputInteractionEvent event) {
6060
return error(event, "Word must be between 4 and 50 characters");
6161
}
6262
var ctx = resolver.resolveOptions(event);
63-
if (ctx.errorSet) return error(event, ctx.errorMessage);
63+
if (ctx.isErrorSet()) return error(event, ctx.getErrorMessage());
6464
return resolve(event, word, ctx.page, ctx.startDate, ctx.endDate);
6565
}
6666

src/main/java/vc/commands/ChatsCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public String getName() {
5353

5454
@Override
5555
public Mono<Message> handle(final ChatInputInteractionEvent event) {
56-
ChatInputInteractionCommandContext ctx = resolver.resolveOptions(event);
57-
if (ctx.errorSet) return error(event, ctx.errorMessage);
56+
ChatInteractionOptionContext ctx = resolver.resolveOptions(event);
57+
if (ctx.isErrorSet()) return error(event, ctx.getErrorMessage());
5858
return resolveChats(event, ctx.profileData, ctx.page, ctx.startDate, ctx.endDate);
5959
}
6060

src/main/java/vc/commands/ConnectionsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public String getName() {
5757
@Override
5858
public Mono<Message> handle(final ChatInputInteractionEvent event) {
5959
var ctx = this.resolver.resolveOptions(event);
60-
if (ctx.errorSet) return error(event, ctx.errorMessage);
60+
if (ctx.isErrorSet()) return error(event, ctx.getErrorMessage());
6161
return resolveConnections(event, ctx.profileData, ctx.page, ctx.startDate, ctx.endDate);
6262
}
6363

src/main/java/vc/commands/DeathsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public String getName() {
5757
@Override
5858
public Mono<Message> handle(final ChatInputInteractionEvent event) {
5959
var ctx = resolver.resolveOptions(event);
60-
if (ctx.errorSet) return error(event, ctx.errorMessage);
60+
if (ctx.isErrorSet()) return error(event, ctx.getErrorMessage());
6161
return resolveDeaths(event, ctx.profileData, ctx.page, ctx.startDate, ctx.endDate);
6262
}
6363

src/main/java/vc/commands/PlayerStatsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public String getName() {
3838
@Override
3939
public Mono<Message> handle(final ChatInputInteractionEvent event) {
4040
var ctx = resolver.resolveOptions(event);
41-
if (ctx.errorSet) return error(event, ctx.errorMessage);
41+
if (ctx.isErrorSet()) return error(event, ctx.getErrorMessage());
4242
var identity = ctx.profileData;
4343
PlayerStats playerStats = null;
4444
try {

src/main/java/vc/commands/PlaytimeCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public String getName() {
3939
@Override
4040
public Mono<Message> handle(final ChatInputInteractionEvent event) {
4141
var ctx = resolver.resolveOptions(event);
42-
if (ctx.errorSet) return error(event, ctx.errorMessage);
42+
if (ctx.isErrorSet()) return error(event, ctx.getErrorMessage());
4343
return resolvePlaytime(event, ctx.profileData);
4444
}
4545

src/main/java/vc/commands/SeenCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public String getName() {
4444
@Override
4545
public Mono<Message> handle(final ChatInputInteractionEvent event) {
4646
var ctx = resolver.resolveOptions(event);
47-
if (ctx.errorSet) return error(event, ctx.errorMessage);
47+
if (ctx.isErrorSet()) return error(event, ctx.getErrorMessage());
4848
return resolveSeen(event, ctx.profileData);
4949
}
5050

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package vc.commands.options;
2+
3+
public interface ChatInteractionOption {
4+
void apply(ChatInteractionOptionContext context);
5+
}

src/main/java/vc/commands/options/ChatInputInteractionCommandContext.java renamed to src/main/java/vc/commands/options/ChatInteractionOptionContext.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,29 @@
55

66
import java.time.LocalDate;
77

8-
public class ChatInputInteractionCommandContext {
9-
public boolean errorSet = false;
10-
public String errorMessage = "";
8+
public class ChatInteractionOptionContext {
9+
private boolean errorSet = false;
10+
private String errorMessage = "";
1111
public final ChatInputInteractionEvent event;
12-
public int page = 1;
12+
public int page;
1313
public ProfileData profileData;
1414
public LocalDate startDate;
1515
public LocalDate endDate;
1616

17-
public ChatInputInteractionCommandContext(final ChatInputInteractionEvent event) {
17+
public ChatInteractionOptionContext(final ChatInputInteractionEvent event) {
1818
this.event = event;
1919
}
2020

2121
public void setError(String message) {
2222
this.errorSet = true;
2323
this.errorMessage = message;
2424
}
25+
26+
public boolean isErrorSet() {
27+
return errorSet;
28+
}
29+
30+
public String getErrorMessage() {
31+
return errorMessage;
32+
}
2533
}

src/main/java/vc/commands/options/ChatInteractionOptionInstance.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)