Compare commits

..

No commits in common. "9e52347be386cc919b483ab14353773d9821bcd6" and "15c5c2c50a522b22d45f7479c48e142cf8d81d76" have entirely different histories.

2 changed files with 7 additions and 17 deletions

View file

@ -68,9 +68,9 @@ async def livegameworker(self,serverid,userid,channelid,messageid,gameid,offset)
embed.add_field(name="Outs",value="🔴🔴") embed.add_field(name="Outs",value="🔴🔴")
case _: case _:
embed.add_field(name="Outs",value="⭕⭕") embed.add_field(name="Outs",value="⭕⭕")
embed.add_field(name="Batting",value=f"{data["entries"][-1]["batter"]}.", inline=True) embed.add_field(name="Batting",value=data["entries"][-1]["batter"], inline=True)
embed.add_field(name="Pitching",value=f"{data["entries"][-1]["pitcher"]}.", inline=True) embed.add_field(name="Pitching",value=data["entries"][-1]["pitcher"], inline=True)
embed.add_field(name="On Deck",value=f"{data["entries"][-1]["on_deck"]}.", inline=True) embed.add_field(name="On Deck",value=data["entries"][-1]["on_deck"], inline=True)
embed.add_field(name=f"Last 7 events",value=finalstr[-1024:],inline=False) embed.add_field(name=f"Last 7 events",value=finalstr[-1024:],inline=False)
embed.set_thumbnail(f"https://insertapp.net/mmolbbot/assets/diamond_{data["entries"][-1]["on_1b"]}_{data["entries"][-1]["on_2b"]}_{data["entries"][-1]["on_3b"]}.png") embed.set_thumbnail(f"https://insertapp.net/mmolbbot/assets/diamond_{data["entries"][-1]["on_1b"]}_{data["entries"][-1]["on_2b"]}_{data["entries"][-1]["on_3b"]}.png")
embed.set_footer(text=f"Embed too big? Need historical data? consider classic mode.") embed.set_footer(text=f"Embed too big? Need historical data? consider classic mode.")
@ -517,11 +517,6 @@ class liveupdate(commands.Cog):
finalstr = "Last 12 timings:" finalstr = "Last 12 timings:"
for i in timings: for i in timings:
finalstr += f"\n{i}s" finalstr += f"\n{i}s"
interval = round((sum(timings)/len(timings)),3)
if interval < 5:
interval = 5
finalstr += f"\nNew interval: {interval}"
self.updatelivegames.change_interval(seconds=interval)
await warning.send(finalstr) await warning.send(finalstr)
timings.clear() timings.clear()
except Exception as e: except Exception as e:
@ -537,14 +532,9 @@ class liveupdate(commands.Cog):
try: try:
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
try: game = await session.get("https://mmolb.com/api/spotlight")
game = await session.get("https://mmolb.com/api/spotlight") game = await game.json()
game = await game.json() gameid = game["game_id"]
gameid = game["game_id"]
except KeyError:
game = await session.get("https://mmolb.com/api/event-games")
game = await game.json()
gameid = game["games"][-1]["game_id"]
data = await session.get(f"https://mmolb.com/api/game/{gameid}") data = await session.get(f"https://mmolb.com/api/game/{gameid}")
data = await data.json() data = await data.json()
res = await self.bot.db.execute("SELECT serverid,channelid,classic FROM spotlightsubscriptions") res = await self.bot.db.execute("SELECT serverid,channelid,classic FROM spotlightsubscriptions")

View file

@ -216,7 +216,7 @@ class TeamView(nextcord.ui.View):
embed = ogmsg[0] embed = ogmsg[0]
teamid = embed.footer.text teamid = embed.footer.text
data = requests.get(f"https://mmolb.com/api/team/{teamid}").json() data = requests.get(f"https://mmolb.com/api/team/{teamid}").json()
history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=3").json()["items"] history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=2").json()["items"]
color = tuple(int(data["Color"][i:i+2], 16) for i in (0, 2, 4)) 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 = 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) embed.set_footer(text=teamid)