mirror of
https://github.com/insertapp/mmolbbot.git
synced 2025-08-02 11:13:32 +00:00
Compare commits
No commits in common. "0ad64bc326bc94f05f84df09dfde73faf7d02e1b" and "78ded6d7b7532171b4b06dc92b2f043051887e64" have entirely different histories.
0ad64bc326
...
78ded6d7b7
3 changed files with 3 additions and 56 deletions
|
@ -23,7 +23,6 @@ class error(commands.Cog):
|
||||||
random.shuffle(errormsg)
|
random.shuffle(errormsg)
|
||||||
strerror = "".join(error)
|
strerror = "".join(error)
|
||||||
print(strerror, file=sys.stderr)
|
print(strerror, file=sys.stderr)
|
||||||
await self.bot.application_info()
|
|
||||||
message = f"{errormsg[0]}\n```py\n{strerror[-1800:]}\n```\n Contact <@{self.bot.owner_id}> if the error persists"
|
message = f"{errormsg[0]}\n```py\n{strerror[-1800:]}\n```\n Contact <@{self.bot.owner_id}> if the error persists"
|
||||||
try:
|
try:
|
||||||
await interaction.response.send_message(message, ephemeral=True)
|
await interaction.response.send_message(message, ephemeral=True)
|
||||||
|
|
|
@ -8,7 +8,6 @@ import nextcord
|
||||||
import aiosqlite as sqlite3
|
import aiosqlite as sqlite3
|
||||||
from nextcord.ext import commands, application_checks, tasks
|
from nextcord.ext import commands, application_checks, tasks
|
||||||
from nextcord import TextInputStyle, IntegrationType
|
from nextcord import TextInputStyle, IntegrationType
|
||||||
import itertools
|
|
||||||
|
|
||||||
leagues_dict = {}
|
leagues_dict = {}
|
||||||
leagues_list = []
|
leagues_list = []
|
||||||
|
@ -38,46 +37,5 @@ class league(commands.Cog):
|
||||||
self.bot.leagues_list = leagues_list
|
self.bot.leagues_list = leagues_list
|
||||||
self.bot.leagues_dict = leagues_dict
|
self.bot.leagues_dict = leagues_dict
|
||||||
|
|
||||||
|
|
||||||
@nextcord.slash_command(
|
|
||||||
name="ranking",
|
|
||||||
description="Get a leaguess overall rankings",
|
|
||||||
integration_types=[
|
|
||||||
IntegrationType.user_install,
|
|
||||||
IntegrationType.guild_install,
|
|
||||||
],
|
|
||||||
contexts=[
|
|
||||||
nextcord.InteractionContextType.guild,
|
|
||||||
nextcord.InteractionContextType.bot_dm,
|
|
||||||
nextcord.InteractionContextType.private_channel,
|
|
||||||
],
|
|
||||||
force_global=True,
|
|
||||||
)
|
|
||||||
async def leaguesranking(self, interaction: nextcord.Interaction, league: str):
|
|
||||||
if league not in leagues_dict:
|
|
||||||
await interaction.response.send_message("Invalid league!", ephemeral=True)
|
|
||||||
return
|
|
||||||
await interaction.response.defer()
|
|
||||||
leagueid = leagues_dict[league]
|
|
||||||
basedata = requests.get(f"https://mmolb.com/api/league/{leagueid}").json()
|
|
||||||
rankdata = requests.get(f"https://mmolb.com/api/league-top-teams/{leagueid}").json()
|
|
||||||
color = tuple(int(basedata["Color"][i:i+2], 16) for i in (0, 2, 4))
|
|
||||||
embed = nextcord.Embed(title=f"Top teams for the {basedata["Name"]} League {basedata["Emoji"]}", colour = nextcord.Color.from_rgb(color[0], color[1], color[2]))
|
|
||||||
rankdata = rankdata["teams"]
|
|
||||||
for i in itertools.islice(rankdata, 0, 10):
|
|
||||||
embed.add_field(name=f"{i["Location"]} {i["Name"]} {i["Emoji"]} ", value=f"[{i["Record"]["Regular Season"]["Wins"]}-{i["Record"]["Regular Season"]["Losses"]} ({i["Record"]["Regular Season"]["RunDifferential"]})](<https://mmolb.com/team/{i["_id"]}>)",inline=False)
|
|
||||||
embed.set_footer(text=leagueid)
|
|
||||||
await interaction.edit_original_message(embed=embed)
|
|
||||||
|
|
||||||
@leaguesranking.on_autocomplete("league")
|
|
||||||
async def leaguesrankingac(self, interaction: nextcord.Interaction, league: str):
|
|
||||||
if not league:
|
|
||||||
thanksdiscord = leagues_list[:20]
|
|
||||||
await interaction.response.send_autocomplete(thanksdiscord)
|
|
||||||
return
|
|
||||||
closestteam = [name for name in leagues_list if name.lower().startswith(league.lower())]
|
|
||||||
thanksdiscord = closestteam[:20]
|
|
||||||
await interaction.response.send_autocomplete(thanksdiscord)
|
|
||||||
|
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: commands.Bot):
|
||||||
bot.add_cog(league(bot))
|
bot.add_cog(league(bot))
|
16
cogs/team.py
16
cogs/team.py
|
@ -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=1").json()["items"]
|
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))
|
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)
|
||||||
|
@ -263,23 +263,15 @@ class team(commands.Cog):
|
||||||
)):
|
)):
|
||||||
if team not in teams_dict:
|
if team not in teams_dict:
|
||||||
await interaction.response.send_message("Invalid Team!", ephemeral=True)
|
await interaction.response.send_message("Invalid Team!", ephemeral=True)
|
||||||
return
|
|
||||||
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()
|
||||||
rankdata = requests.get(f"https://mmolb.com/api/league-top-teams/{data["League"]}").json()["teams"]
|
|
||||||
ranking = 0
|
|
||||||
for i in rankdata:
|
|
||||||
ranking += 1
|
|
||||||
if i["_id"] == teamid:
|
|
||||||
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"{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="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)
|
||||||
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="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)
|
||||||
|
@ -315,7 +307,6 @@ class team(commands.Cog):
|
||||||
)):
|
)):
|
||||||
if team not in teams_dict:
|
if team not in teams_dict:
|
||||||
await interaction.response.send_message("Invalid Team!", ephemeral=True)
|
await interaction.response.send_message("Invalid Team!", ephemeral=True)
|
||||||
return
|
|
||||||
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()
|
||||||
|
@ -349,8 +340,8 @@ class team(commands.Cog):
|
||||||
|
|
||||||
|
|
||||||
@nextcord.slash_command(
|
@nextcord.slash_command(
|
||||||
name="players",
|
name="teamstats",
|
||||||
description="Get a team's player statistics",
|
description="Get a teams stats",
|
||||||
integration_types=[
|
integration_types=[
|
||||||
IntegrationType.user_install,
|
IntegrationType.user_install,
|
||||||
IntegrationType.guild_install,
|
IntegrationType.guild_install,
|
||||||
|
@ -365,7 +356,6 @@ class team(commands.Cog):
|
||||||
async def teamstats(self, interaction: nextcord.Interaction, team: str):
|
async def teamstats(self, interaction: nextcord.Interaction, team: str):
|
||||||
if team not in teams_dict:
|
if team not in teams_dict:
|
||||||
await interaction.response.send_message("Invalid Team!", ephemeral=True)
|
await interaction.response.send_message("Invalid Team!", ephemeral=True)
|
||||||
return
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
teamid = teams_dict[team]
|
teamid = teams_dict[team]
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
Loading…
Reference in a new issue