mirror of
https://github.com/insertapp/mmolbbot.git
synced 2025-08-01 18:53:33 +00:00
Compare commits
2 commits
15c5c2c50a
...
9e52347be3
Author | SHA1 | Date | |
---|---|---|---|
9e52347be3 | |||
c77964c255 |
2 changed files with 17 additions and 7 deletions
|
@ -68,9 +68,9 @@ async def livegameworker(self,serverid,userid,channelid,messageid,gameid,offset)
|
|||
embed.add_field(name="Outs",value="🔴🔴")
|
||||
case _:
|
||||
embed.add_field(name="Outs",value="⭕⭕")
|
||||
embed.add_field(name="Batting",value=data["entries"][-1]["batter"], inline=True)
|
||||
embed.add_field(name="Pitching",value=data["entries"][-1]["pitcher"], inline=True)
|
||||
embed.add_field(name="On Deck",value=data["entries"][-1]["on_deck"], inline=True)
|
||||
embed.add_field(name="Batting",value=f"{data["entries"][-1]["batter"]}.", inline=True)
|
||||
embed.add_field(name="Pitching",value=f"{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=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_footer(text=f"Embed too big? Need historical data? consider classic mode.")
|
||||
|
@ -517,6 +517,11 @@ class liveupdate(commands.Cog):
|
|||
finalstr = "Last 12 timings:"
|
||||
for i in timings:
|
||||
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)
|
||||
timings.clear()
|
||||
except Exception as e:
|
||||
|
@ -532,9 +537,14 @@ class liveupdate(commands.Cog):
|
|||
try:
|
||||
await self.bot.wait_until_ready()
|
||||
async with aiohttp.ClientSession() as session:
|
||||
game = await session.get("https://mmolb.com/api/spotlight")
|
||||
game = await game.json()
|
||||
gameid = game["game_id"]
|
||||
try:
|
||||
game = await session.get("https://mmolb.com/api/spotlight")
|
||||
game = await game.json()
|
||||
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 data.json()
|
||||
res = await self.bot.db.execute("SELECT serverid,channelid,classic FROM spotlightsubscriptions")
|
||||
|
|
|
@ -216,7 +216,7 @@ class TeamView(nextcord.ui.View):
|
|||
embed = ogmsg[0]
|
||||
teamid = embed.footer.text
|
||||
data = requests.get(f"https://mmolb.com/api/team/{teamid}").json()
|
||||
history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=2").json()["items"]
|
||||
history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=3").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)
|
||||
|
|
Loading…
Reference in a new issue