Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidetacchini committed Sep 20, 2023
2 parents c7b982f + 5086a14 commit 43a5e30
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

log = logging.getLogger("overbot")

__version__ = "6.0.1"
__version__ = "6.0.2"


class OverBot(commands.AutoShardedBot):
Expand Down
8 changes: 4 additions & 4 deletions classes/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _resolve_ratings(self, *, platform: str) -> None | dict[str, int]:
ratings[key.lower()] = f"**{value['division'].capitalize()} {str(value['tier'])}**"
return ratings

async def _resolve_stats(
def _resolve_stats(
self, platform: str, hero: str, /
) -> None | tuple[list[str], dict[str, Any], dict[str, Any]]:
try:
Expand Down Expand Up @@ -180,7 +180,7 @@ def _format_stats(
c_temp = "\n".join(f"{k}: **{v}**" for k, v in competitive[key].items())
embed.add_field(name="Competitive", value=self._format_key(c_temp))

async def embed_ratings(self) -> dict[str, discord.Embed]:
def embed_ratings(self) -> dict[str, discord.Embed]:
ratings = {}
for platform in self._platforms:
embed = discord.Embed(color=self.bot.color(self.interaction.user.id))
Expand All @@ -200,14 +200,14 @@ async def embed_ratings(self) -> dict[str, discord.Embed]:
ratings[platform] = embed
return ratings

async def embed_stats(self, hero: str) -> dict[str, discord.Embed | list[discord.Embed]]:
def embed_stats(self, hero: str) -> dict[str, discord.Embed | list[discord.Embed]]:
stats = {}
for platform in self._platforms:
embed = discord.Embed(color=self.bot.color(self.interaction.user.id))
username = f"{self.username} [{platform.upper()}]"
embed.set_author(name=username, icon_url=self.avatar)

career_stats = await self._resolve_stats(platform, hero)
career_stats = self._resolve_stats(platform, hero)
if career_stats is None:
embed.description = "There is no data for this account in this mode yet."
stats[platform] = embed
Expand Down
13 changes: 13 additions & 0 deletions cogs/overwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ async def hero(self, interaction: discord.Interaction, name: str) -> None:
url = f"{self.bot.BASE_URL}/heroes/{name}"
async with ClientSession() as s:
async with s.get(url) as r:
if r.status == 422:
await interaction.response.send_message(f"Hero **{name}** not found.")
return
if r.status != 200:
raise UnknownError()
data = await r.json()
Expand All @@ -268,6 +271,11 @@ async def hero(self, interaction: discord.Interaction, name: str) -> None:
@app_commands.describe(name="The name of the map to see information for")
async def map(self, interaction: discord.Interaction, name: str) -> None:
"""Returns information about a given map"""
map_ = self.bot.maps.get(name)
if map_ is None:
await interaction.response.send_message(f"Map **{name}** not found.")
return

embed = await self.embed_map_info(name)
await interaction.response.send_message(embed=embed)

Expand All @@ -276,6 +284,11 @@ async def map(self, interaction: discord.Interaction, name: str) -> None:
@app_commands.describe(name="The name of the gamemode to see information for")
async def gamemode(self, interaction: discord.Interaction, name: str) -> None:
"""Returns information about a given gamemode"""
gamemode = self.bot.gamemodes.get(name)
if gamemode is None:
await interaction.response.send_message(f"Gamemode **{name}** not found.")
return

embed = await self.embed_gamemode_info(name)
await interaction.response.send_message(embed=embed)

Expand Down
5 changes: 3 additions & 2 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"include": [
"classes",
"cogs",
"utils"
"utils",
"bot.py"
],
"exclude": [
"**/__pycache__",
"env",
".git"
],
"pythonVersion": "3.10",
"pythonVersion": "3.11",
"typeCheckingMode": "basic",
"strictParameterNoneValue": false,
"reportUnnecessaryTypeIgnoreComment": "warning",
Expand Down

0 comments on commit 43a5e30

Please sign in to comment.