From e7bda94b6d905429b8d340e36ff37068d238987a Mon Sep 17 00:00:00 2001 From: davidetacchini <84925446+davidetacchini@users.noreply.github.com> Date: Wed, 20 Sep 2023 20:13:54 +0200 Subject: [PATCH 1/4] bump python version to 3.11; include bot.py --- pyrightconfig.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index fa2221b4..37c5dde4 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -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", From e92c92ae0e8f86205e05e7bbbbb575085894bd7c Mon Sep 17 00:00:00 2001 From: davidetacchini <84925446+davidetacchini@users.noreply.github.com> Date: Wed, 20 Sep 2023 20:14:39 +0200 Subject: [PATCH 2/4] remove unnecessary async/await --- classes/profile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/profile.py b/classes/profile.py index 0dc4cb1b..b84bfdf9 100644 --- a/classes/profile.py +++ b/classes/profile.py @@ -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: @@ -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)) @@ -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 From 5a375658c49899f873e09abede9ae75a00586e65 Mon Sep 17 00:00:00 2001 From: davidetacchini <84925446+davidetacchini@users.noreply.github.com> Date: Wed, 20 Sep 2023 21:45:48 +0200 Subject: [PATCH 3/4] check for hero, map and gamemode to exists --- cogs/overwatch.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cogs/overwatch.py b/cogs/overwatch.py index e881191c..87e9e070 100644 --- a/cogs/overwatch.py +++ b/cogs/overwatch.py @@ -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() @@ -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) @@ -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) From 5086a14e24f9ec7386064568c22ce90c1bb08932 Mon Sep 17 00:00:00 2001 From: davidetacchini <84925446+davidetacchini@users.noreply.github.com> Date: Wed, 20 Sep 2023 21:46:49 +0200 Subject: [PATCH 4/4] version bump to 6.0.2 --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 65c6be25..e206d4c4 100644 --- a/bot.py +++ b/bot.py @@ -26,7 +26,7 @@ log = logging.getLogger("overbot") -__version__ = "6.0.1" +__version__ = "6.0.2" class OverBot(commands.AutoShardedBot):