mirror of
https://github.com/insertapp/mmolbbot.git
synced 2025-07-01 14:27:03 +00:00
fix: gamehistory not working
This commit is contained in:
parent
7824db4342
commit
c3f1832ac3
1 changed files with 20 additions and 20 deletions
40
cogs/team.py
40
cogs/team.py
|
@ -215,21 +215,21 @@ 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://lunanova.space/mmolb/api/gamesbyteam/{teamid}").json()
|
||||
history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=0").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)
|
||||
for index in itertools.islice(history, (len(history)-10 if len(history)-10 > 0 else 0) , len(history)):
|
||||
if history[index]["away_team_id"] != teamid:
|
||||
awayteamid = history[index]["away_team_id"]
|
||||
otherscore = history[index]["away_score"]
|
||||
ourscore = history[index]["home_score"]
|
||||
for index in reversed(list(itertools.islice(history, (len(history)-10 if len(history)-10 > 0 else 0) , len(history)))):
|
||||
if index["away_team_id"] != teamid:
|
||||
awayteamid = index["away_team_id"]
|
||||
otherscore = index["last_update"]["away_score"]
|
||||
ourscore = index["last_update"]["home_score"]
|
||||
else:
|
||||
awayteamid = history[index]["home_team_id"]
|
||||
otherscore = history[index]["home_score"]
|
||||
ourscore = history[index]["away_score"]
|
||||
awayteamid = index["home_team_id"]
|
||||
otherscore = index["last_update"]["home_score"]
|
||||
ourscore = index["last_update"]["away_score"]
|
||||
tempdata = requests.get(f"https://mmolb.com/api/team/{awayteamid}").json()
|
||||
embed.add_field(name=f"vs. {tempdata["Location"]} {tempdata["Name"]} {tempdata["Emoji"]} ({ourscore} - {otherscore})", value=f"[watch](<https://mmolb.com/watch/{index}>)", inline=False)
|
||||
embed.add_field(name=f"vs. {tempdata["Location"]} {tempdata["Name"]} {tempdata["Emoji"]} ({ourscore} - {otherscore})", value=f"[watch](<https://mmolb.com/watch/{index['game_id']}>)", inline=False)
|
||||
await interaction.followup.send(embed=embed,ephemeral=True)
|
||||
|
||||
class team(commands.Cog):
|
||||
|
@ -308,21 +308,21 @@ 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://lunanova.space/mmolb/api/gamesbyteam/{teamid}").json()
|
||||
history = requests.get(f"https://freecashe.ws/api/games?team={teamid}&season=0").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)
|
||||
for index in itertools.islice(history, (len(history)-10 if len(history)-10 > 0 else 0) , len(history)):
|
||||
if history[index]["away_team_id"] != teamid:
|
||||
awayteamid = history[index]["away_team_id"]
|
||||
otherscore = history[index]["away_score"]
|
||||
ourscore = history[index]["home_score"]
|
||||
for index in reversed(list(itertools.islice(history, (len(history)-10 if len(history)-10 > 0 else 0) , len(history)))):
|
||||
if index["away_team_id"] != teamid:
|
||||
awayteamid = index["away_team_id"]
|
||||
otherscore = index["last_update"]["away_score"]
|
||||
ourscore = index["last_update"]["home_score"]
|
||||
else:
|
||||
awayteamid = history[index]["home_team_id"]
|
||||
otherscore = history[index]["home_score"]
|
||||
ourscore = history[index]["away_score"]
|
||||
awayteamid = index["home_team_id"]
|
||||
otherscore = index["last_update"]["home_score"]
|
||||
ourscore = index["last_update"]["away_score"]
|
||||
tempdata = requests.get(f"https://mmolb.com/api/team/{awayteamid}").json()
|
||||
embed.add_field(name=f"vs. {tempdata["Location"]} {tempdata["Name"]} {tempdata["Emoji"]} ({ourscore} - {otherscore})", value=f"[watch](<https://mmolb.com/watch/{index}>)", inline=False)
|
||||
embed.add_field(name=f"vs. {tempdata["Location"]} {tempdata["Name"]} {tempdata["Emoji"]} ({ourscore} - {otherscore})", value=f"[watch](<https://mmolb.com/watch/{index['game_id']}>)", inline=False)
|
||||
await interaction.edit_original_message(embed=embed)
|
||||
|
||||
@gamehistory.on_autocomplete("team")
|
||||
|
|
Loading…
Reference in a new issue