diff options
| -rw-r--r-- | bot/exts/evergreen/error_handler.py | 9 | ||||
| -rw-r--r-- | bot/exts/evergreen/wikipedia.py | 24 | 
2 files changed, 6 insertions, 27 deletions
| diff --git a/bot/exts/evergreen/error_handler.py b/bot/exts/evergreen/error_handler.py index 8fcbb8f2..7a916606 100644 --- a/bot/exts/evergreen/error_handler.py +++ b/bot/exts/evergreen/error_handler.py @@ -113,10 +113,7 @@ class CommandErrorHandler(commands.Cog):              return          if isinstance(error, commands.CheckFailure): -            await ctx.send( -                embed=self.error_embed( -                    "You are not authorized to use this command.", -                    NEGATIVE_REPLIES)) +            await ctx.send(embed=self.error_embed("You are not authorized to use this command.", NEGATIVE_REPLIES))              return          if isinstance(error, UserNotPlayingError): @@ -127,7 +124,9 @@ class CommandErrorHandler(commands.Cog):              await ctx.send(                  embed=self.error_embed(                      f"There was an error when communicating with the {error.api}", -                    NEGATIVE_REPLIES)) +                    NEGATIVE_REPLIES +                ) +            )              return          with push_scope() as scope: diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index 63462433..35ab27f1 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -48,31 +48,11 @@ class WikipediaSearch(commands.Cog):          params = WIKI_PARAMS | {"srlimit": 10, "srsearch": search}          async with self.bot.http_session.get(url=SEARCH_API, params=params) as resp:              if (status := resp.status) != 200: -                log.info(f"Unexpected response `{resp.status}` while searching wikipedia for `{search}`") +                log.info(f"Unexpected response `{status}` while searching wikipedia for `{search}`")                  raise ExternalAPIError("Wikipedia API", status) -            raw_data = await resp.json() -            number_of_results = raw_data["query"]["searchinfo"]["totalhits"] - -            if number_of_results: -                results = raw_data["query"]["search"] -                lines = [] - -                for article in results: -                    line = WIKI_SEARCH_RESULT.format( -                        name=article["title"], -                        description=unescape( -                            re.sub( -                                WIKI_SNIPPET_REGEX, "", article["snippet"] -                            ) -                        ), -                        url=f"https://en.wikipedia.org/?curid={article['pageid']}" -                    ) -                    lines.append(line) - -                return lines              raw_data = await resp.json() -            if not raw_data.get("query", None): +            if not raw_data.get("query"):                  if error := raw_data.get("errors"):                      log.error(f"There was an error while communicating with the Wikipedia API: {error}")                  raise ExternalAPIError("Wikipedia API", status, error) | 
