mirror of
https://github.com/insertapp/mmolbbot.git
synced 2025-07-01 22:37:04 +00:00
fix: no response if team has no players
This commit is contained in:
parent
038122f6ed
commit
eb9ce9be11
1 changed files with 4 additions and 2 deletions
|
@ -117,8 +117,9 @@ def get_json(url: str) -> dict:
|
||||||
def teamstats(MY_TEAM_ID):
|
def teamstats(MY_TEAM_ID):
|
||||||
finalstr = ""
|
finalstr = ""
|
||||||
team_obj = get_json(f"https://mmolb.com/api/team/{MY_TEAM_ID}")
|
team_obj = get_json(f"https://mmolb.com/api/team/{MY_TEAM_ID}")
|
||||||
|
|
||||||
for player in team_obj["Players"]:
|
for player in team_obj["Players"]:
|
||||||
|
if player['FirstName'] == 'Empty' and player["LastName"] == "Slot":
|
||||||
|
continue
|
||||||
player_obj = get_json(f"https://mmolb.com/api/player/{player['PlayerID']}")
|
player_obj = get_json(f"https://mmolb.com/api/player/{player['PlayerID']}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -176,7 +177,7 @@ def teamstats(MY_TEAM_ID):
|
||||||
finalstr += "" * (30 - (len(player["Position"]) + len(player["FirstName"]) + len(player["LastName"])))
|
finalstr += "" * (30 - (len(player["Position"]) + len(player["FirstName"]) + len(player["LastName"])))
|
||||||
finalstr += f"{stats_str}\n"
|
finalstr += f"{stats_str}\n"
|
||||||
|
|
||||||
return finalstr
|
return (finalstr if finalstr != "" else "There are no players on this team")
|
||||||
|
|
||||||
|
|
||||||
def dot_format(in_val: float) -> str:
|
def dot_format(in_val: float) -> str:
|
||||||
|
@ -267,6 +268,7 @@ class team(commands.Cog):
|
||||||
data = requests.get(f"https://mmolb.com/api/team/{teamid}").json()
|
data = requests.get(f"https://mmolb.com/api/team/{teamid}").json()
|
||||||
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"{data["Motto"]}", colour = nextcord.Color.from_rgb(color[0], color[1], color[2]))
|
embed = nextcord.Embed(title=f"{data["Location"]} {data["Name"]} {data["Emoji"]}", description=f"{data["Motto"]}", 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="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)
|
||||||
|
|
Loading…
Reference in a new issue