diff --git a/cogs/liveupdate.py b/cogs/liveupdate.py index f1d0041..d86cccc 100644 --- a/cogs/liveupdate.py +++ b/cogs/liveupdate.py @@ -97,16 +97,22 @@ class liveupdate(commands.Cog): await interaction.response.send_message("Invalid Team!", ephemeral=True) await interaction.response.defer() teamid = self.bot.teams_dict[team] - game = requests.get(f"https://mmolb.com/api/game-by-team/{teamid}").json() - gameid = game["game_id"] - data = requests.get(f"https://mmolb.com/api/game/{gameid}").json() - await interaction.edit_original_message(content=f"{data["AwayTeamName"]} {data["AwayTeamEmoji"]} **{data["EventLog"][-1]["away_score"]}** vs {data["HomeTeamName"]} {data["HomeTeamEmoji"]} **{data["EventLog"][-1]["home_score"]}**") - message = await interaction.original_message() - if data["State"] != "Complete": - await self.bot.db.execute(f""" - INSERT INTO liveupdate VALUES - ({interaction.guild_id}, {interaction.user.id}, {interaction.channel_id}, {message.id}, "{gameid}", {len(data["EventLog"])}) - """) + try: + game = requests.get(f"https://mmolb.com/api/game-by-team/{teamid}").json() + gameid = game["game_id"] + data = requests.get(f"https://mmolb.com/api/game/{gameid}").json() + await interaction.edit_original_message(content=f"{data["AwayTeamName"]} {data["AwayTeamEmoji"]} **{data["EventLog"][-1]["away_score"]}** vs {data["HomeTeamName"]} {data["HomeTeamEmoji"]} **{data["EventLog"][-1]["home_score"]}**") + message = await interaction.original_message() + if data["State"] != "Complete": + await self.bot.db.execute(f""" + INSERT INTO liveupdate VALUES + ({interaction.guild_id}, {interaction.user.id}, {interaction.channel_id}, {message.id}, "{gameid}", {len(data["EventLog"])}) + """) + except Exception as e: + await interaction.edit_original_message(content="This channel is now subscribed to updates") + warning = self.bot.get_channel(1365478368555827270) + await warning.send(e) + print(e) await self.bot.db.execute(f""" INSERT INTO teamsubscriptions VALUES ({interaction.guild_id}, {interaction.channel_id}, "{teamid}") diff --git a/cogs/team.py b/cogs/team.py index c798cc9..0234d1f 100644 --- a/cogs/team.py +++ b/cogs/team.py @@ -310,7 +310,7 @@ class team(commands.Cog): await interaction.response.defer() teamid = teams_dict[team] data = requests.get(f"https://mmolb.com/api/team/{teamid}").json() - history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=0").json()["items"] + history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=1").json()["items"] color = tuple(int(data["Color"][i:i+2], 16) for i in (0, 2, 4)) embed = nextcord.Embed(title=f"Last ten games for the {data["Location"]} {data["Name"]} {data["Emoji"]}", colour = nextcord.Color.from_rgb(color[0], color[1], color[2])) embed.set_footer(text=teamid)