Skip to content

Commit a86bb1b

Browse files
committed
fix: return no choices when there's no games today
1 parent 2bb9047 commit a86bb1b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/pw/chew/mlb/util/AutocompleteUtil.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ public static List<Command.Choice> getTodayGames(boolean showFinal) {
155155
// Build games
156156
List<Command.Choice> choices = new ArrayList<>();
157157

158-
JSONArray games = gameResponse.getJSONArray("dates").getJSONObject(0).getJSONArray("games");
158+
JSONArray dates = gameResponse.getJSONArray("dates");
159+
160+
// No games today
161+
if (dates.isEmpty()) {
162+
return choices;
163+
}
164+
165+
JSONArray games = dates.getJSONObject(0).getJSONArray("games");
159166

160167
for (int i = 0; i < games.length(); i++) {
161168
JSONObject game = games.getJSONObject(i);

0 commit comments

Comments
 (0)