mirror of
https://github.com/insertapp/mmolbbot.git
synced 2025-08-02 03:03:34 +00:00
fix: season 4 changes
This commit is contained in:
parent
9d8ad73c51
commit
f4a12a1da0
2 changed files with 18 additions and 15 deletions
|
@ -302,9 +302,9 @@ async def feedsubscriptionworker(self,serverid,channelid,teamid,offset):
|
||||||
channel = self.bot.get_channel(channelid)
|
channel = self.bot.get_channel(channelid)
|
||||||
if channel is None:
|
if channel is None:
|
||||||
return
|
return
|
||||||
data = await session.get(f"https://mmolb.com/api/team/{teamid}")
|
data = await session.get(f"https://mmolb.com/api/feed?team={teamid}")
|
||||||
data = await data.json()
|
data = await data.json()
|
||||||
data = data['Feed']
|
data = data['feed']
|
||||||
if len(data) > offset:
|
if len(data) > offset:
|
||||||
finalstr = ""
|
finalstr = ""
|
||||||
for index in itertools.islice(data, offset, len(data)):
|
for index in itertools.islice(data, offset, len(data)):
|
||||||
|
@ -531,7 +531,7 @@ class liveupdate(commands.Cog):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
teamid = self.bot.teams_dict[team]
|
teamid = self.bot.teams_dict[team]
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
data = await session.get(f"https://mmolb.com/api/team/{teamid}")
|
data = await session.get(f"https://mmolb.com/api/feed?team={teamid}")
|
||||||
data = await data.json()
|
data = await data.json()
|
||||||
offset = len(data['Feed'])
|
offset = len(data['Feed'])
|
||||||
await self.bot.db.execute(f"""
|
await self.bot.db.execute(f"""
|
||||||
|
|
27
cogs/team.py
27
cogs/team.py
|
@ -217,7 +217,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=4").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)
|
||||||
|
@ -243,12 +243,14 @@ class TeamView(nextcord.ui.View):
|
||||||
embed = ogmsg[0]
|
embed = ogmsg[0]
|
||||||
teamid = embed.footer.text
|
teamid = embed.footer.text
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
data = await session.get(f"https://mmolb.com/api/team/{teamid}")
|
basedata = await session.get(f"https://mmolb.com/api/team/{teamid}")
|
||||||
|
basedata = await basedata.json()
|
||||||
|
data = await session.get(f"https://mmolb.com/api/feed?team={teamid}")
|
||||||
data = await data.json()
|
data = await data.json()
|
||||||
color = tuple(int(data["Color"][i:i+2], 16) for i in (0, 2, 4))
|
color = tuple(int(basedata["Color"][i:i+2], 16) for i in (0, 2, 4))
|
||||||
embed = nextcord.Embed(title=f"Last ten feed events 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 feed events for the {basedata["Location"]} {basedata["Name"]} {basedata["Emoji"]}", colour = nextcord.Color.from_rgb(color[0], color[1], color[2]))
|
||||||
embed.set_footer(text=teamid)
|
embed.set_footer(text=teamid)
|
||||||
data = data['Feed']
|
data = data['feed']
|
||||||
for index in itertools.islice(data, (len(data)-10 if len(data)-10 > 0 else 0) , len(data)):
|
for index in itertools.islice(data, (len(data)-10 if len(data)-10 > 0 else 0) , len(data)):
|
||||||
embed.add_field(name=f"{index['emoji']} Day {index['day']} Season {index['season']}", value=index['text'], inline=False)
|
embed.add_field(name=f"{index['emoji']} Day {index['day']} Season {index['season']}", value=index['text'], inline=False)
|
||||||
await interaction.followup.send(embed=embed,ephemeral=True)
|
await interaction.followup.send(embed=embed,ephemeral=True)
|
||||||
|
@ -294,14 +296,13 @@ class team(commands.Cog):
|
||||||
if i["_id"] == teamid:
|
if i["_id"] == teamid:
|
||||||
break
|
break
|
||||||
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"{data["Location"]} {data["Name"]} {data["Emoji"]}",description=f"{"Inactive" if not data['Active'] else "Active"}", colour = nextcord.Color.from_rgb(color[0], color[1], color[2]))
|
embed = nextcord.Embed(title=f"{data["Location"]} {data["Name"]} {data["Emoji"]}", colour = nextcord.Color.from_rgb(color[0], color[1], color[2]))
|
||||||
embed.add_field(name="League", value=f"{dict((v,k) for k,v in self.bot.leagues_dict.items())[data["League"]]}", inline=True)
|
embed.add_field(name="League", value=f"{dict((v,k) for k,v in self.bot.leagues_dict.items())[data["League"]]}", inline=True)
|
||||||
embed.add_field(name="Ballpark", value=data['BallparkName'])
|
embed.add_field(name="Ballpark", value=data['BallparkName'])
|
||||||
embed.add_field(name="Wins", value=f"{data["Record"]["Regular Season"]["Wins"]}", inline=True)
|
embed.add_field(name="Wins", value=f"{data["Record"]["Regular Season"]["Wins"]}", inline=True)
|
||||||
embed.add_field(name="Losses", value=f"{data["Record"]["Regular Season"]["Losses"]}", inline=True)
|
embed.add_field(name="Losses", value=f"{data["Record"]["Regular Season"]["Losses"]}", inline=True)
|
||||||
embed.add_field(name="Run Differential", value=f"{data["Record"]["Regular Season"]["RunDifferential"]}", inline=True)
|
embed.add_field(name="Run Differential", value=f"{data["Record"]["Regular Season"]["RunDifferential"]}", inline=True)
|
||||||
embed.add_field(name="Rank", value=f"{ranking}", inline=True)
|
embed.add_field(name="Rank", value=f"{ranking}", inline=True)
|
||||||
embed.add_field(name="Augments", value=f"{data["Augments"]}", inline=True)
|
|
||||||
embed.add_field(name="Championships", value=f"{data["Championships"]}", inline=True)
|
embed.add_field(name="Championships", value=f"{data["Championships"]}", inline=True)
|
||||||
embed.set_footer(text=teamid)
|
embed.set_footer(text=teamid)
|
||||||
await interaction.edit_original_message(embed=embed,view=TeamView())
|
await interaction.edit_original_message(embed=embed,view=TeamView())
|
||||||
|
@ -340,7 +341,7 @@ class team(commands.Cog):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
teamid = teams_dict[team]
|
teamid = teams_dict[team]
|
||||||
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=4").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)
|
||||||
|
@ -429,12 +430,14 @@ class team(commands.Cog):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
teamid = teams_dict[team]
|
teamid = teams_dict[team]
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
data = await session.get(f"https://mmolb.com/api/team/{teamid}")
|
basedata = await session.get(f"https://mmolb.com/api/team/{teamid}")
|
||||||
|
basedata = await basedata.json()
|
||||||
|
data = await session.get(f"https://mmolb.com/api/feed?team={teamid}")
|
||||||
data = await data.json()
|
data = await data.json()
|
||||||
color = tuple(int(data["Color"][i:i+2], 16) for i in (0, 2, 4))
|
color = tuple(int(basedata["Color"][i:i+2], 16) for i in (0, 2, 4))
|
||||||
embed = nextcord.Embed(title=f"Last ten feed events 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 feed events for the {basedata["Location"]} {basedata["Name"]} {basedata["Emoji"]}", colour = nextcord.Color.from_rgb(color[0], color[1], color[2]))
|
||||||
embed.set_footer(text=teamid)
|
embed.set_footer(text=teamid)
|
||||||
data = data['Feed']
|
data = data['feed']
|
||||||
for index in itertools.islice(data, (len(data)-10 if len(data)-10 > 0 else 0) , len(data)):
|
for index in itertools.islice(data, (len(data)-10 if len(data)-10 > 0 else 0) , len(data)):
|
||||||
embed.add_field(name=f"{index['emoji']} Day {index['day']} Season {index['season']}", value=index['text'], inline=False)
|
embed.add_field(name=f"{index['emoji']} Day {index['day']} Season {index['season']}", value=index['text'], inline=False)
|
||||||
await interaction.edit_original_message(embed=embed)
|
await interaction.edit_original_message(embed=embed)
|
||||||
|
|
Loading…
Reference in a new issue