diff --git a/src/main/java/pw/chew/mlb/MLBBot.java b/src/main/java/pw/chew/mlb/MLBBot.java index fe9599a..f00e844 100644 --- a/src/main/java/pw/chew/mlb/MLBBot.java +++ b/src/main/java/pw/chew/mlb/MLBBot.java @@ -36,6 +36,8 @@ public class MLBBot { public static final List TEAMS = new ArrayList<>(); public static final EventWaiter waiter = new EventWaiter(); + public static final int SEASON = 2024; + public static void main(String[] args) throws IOException { // Load properties into the PropertiesManager Properties prop = new Properties(); @@ -78,7 +80,7 @@ public static void main(String[] args) throws IOException { RestClient.setClient(jda.getHttpClient()); // Load teams - JSONObject teams = new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/teams?sportIds=1&season=2023")); + JSONObject teams = new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/teams?sportIds=1&season=" + SEASON)); for (int i = 0; i < teams.getJSONArray("teams").length(); i++) { TEAMS.add(teams.getJSONArray("teams").getJSONObject(i)); diff --git a/src/main/java/pw/chew/mlb/commands/PlanGameCommand.java b/src/main/java/pw/chew/mlb/commands/PlanGameCommand.java index 6f0e2e4..d39d94c 100644 --- a/src/main/java/pw/chew/mlb/commands/PlanGameCommand.java +++ b/src/main/java/pw/chew/mlb/commands/PlanGameCommand.java @@ -31,6 +31,8 @@ import java.util.List; import java.util.Map; +import static pw.chew.mlb.MLBBot.SEASON; + public class PlanGameCommand extends SlashCommand { public PlanGameCommand() { this.name = "plangame"; @@ -203,7 +205,7 @@ public void onAutoComplete(CommandAutoCompleteInteractionEvent event) { return; } - JSONArray games = new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/schedule?lang=en&sportId=%S&season=2023&teamId=%S&fields=dates,date,games,gamePk,teams,away,team,teamName,id&hydrate=team".formatted(sport, teamId))) + JSONArray games = new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/schedule?lang=en&sportId=%S&season=%s&teamId=%S&fields=dates,date,games,gamePk,teams,away,team,teamName,id&hydrate=team".formatted(sport, SEASON, teamId))) .getJSONArray("dates"); List choices = new ArrayList<>(); diff --git a/src/main/java/pw/chew/mlb/commands/SetInfoCommand.java b/src/main/java/pw/chew/mlb/commands/SetInfoCommand.java index dda922e..cb1e7fe 100644 --- a/src/main/java/pw/chew/mlb/commands/SetInfoCommand.java +++ b/src/main/java/pw/chew/mlb/commands/SetInfoCommand.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; +import static pw.chew.mlb.MLBBot.SEASON; import static pw.chew.mlb.MLBBot.TEAMS; public class SetInfoCommand extends SlashCommand { @@ -87,7 +88,7 @@ protected void execute(SlashCommandEvent event) { divisionAbbreviation += word.substring(0, 1); } - JSONObject standings = new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/standings?leagueId=103,104&season=2023&standingsTypes=regularSeason")); + JSONObject standings = new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/standings?leagueId=103,104&standingsTypes=regularSeason&season=" + SEASON)); // Gotta find the team now... JSONArray records = standings.getJSONArray("records"); @@ -122,7 +123,7 @@ protected void execute(SlashCommandEvent event) { case "nextgame" -> { int teamId = teamInfo.getInt("id"); - JSONObject teamSchedule = new JSONObject(RestClient.get(String.format("https://statsapi.mlb.com/api/v1/teams/%s?season=2023&hydrate=nextSchedule", teamId))); + JSONObject teamSchedule = new JSONObject(RestClient.get(String.format("https://statsapi.mlb.com/api/v1/teams/%s?season=%s&hydrate=nextSchedule", teamId, SEASON))); JSONObject nextGame = null; diff --git a/src/main/java/pw/chew/mlb/objects/MLBAPIUtil.java b/src/main/java/pw/chew/mlb/objects/MLBAPIUtil.java index 08200d1..f2c874c 100644 --- a/src/main/java/pw/chew/mlb/objects/MLBAPIUtil.java +++ b/src/main/java/pw/chew/mlb/objects/MLBAPIUtil.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; +import static pw.chew.mlb.MLBBot.SEASON; import static pw.chew.mlb.MLBBot.TEAMS; public class MLBAPIUtil { @@ -42,7 +43,7 @@ public static Teams getTeams(String sportId) { if (teamsCache.getIfPresent(sportId) != null) { return teamsCache.getIfPresent(sportId); } - Teams teams = new Teams(new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/teams?sportIds=%s&season=2023".formatted(sportId))).getJSONArray("teams")); + Teams teams = new Teams(new JSONObject(RestClient.get("https://statsapi.mlb.com/api/v1/teams?sportIds=%s&season=%s".formatted(sportId, SEASON))).getJSONArray("teams")); teamsCache.put(sportId, teams); return teams; }