From 397605b14ecb0262d3dfa904a1661eb2514a1d5e Mon Sep 17 00:00:00 2001 From: brad90four <42116429+brad90four@users.noreply.github.com> Date: Mon, 30 Aug 2021 12:13:29 -0400 Subject: Only send articles to user Added the "kind": "article" parameter to the API request. This should only return articles to the user instead of courses, lessons or quizzes. Also updated the "Here are the top x results" message to handle a variable amount of articles. [Ticket: python-discord#828] --- bot/exts/evergreen/realpython.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot/exts/evergreen/realpython.py') diff --git a/bot/exts/evergreen/realpython.py b/bot/exts/evergreen/realpython.py index e722dd4b..6d148ad6 100644 --- a/bot/exts/evergreen/realpython.py +++ b/bot/exts/evergreen/realpython.py @@ -33,7 +33,7 @@ class RealPython(commands.Cog): @commands.cooldown(1, 10, commands.cooldowns.BucketType.user) async def realpython(self, ctx: commands.Context, *, user_search: str) -> None: """Send 5 articles that match the user's search terms.""" - params = {"q": user_search, "limit": 5} + params = {"q": user_search, "limit": 5, "kind": "article"} async with self.bot.http_session.get(url=API_ROOT, params=params) as response: if response.status != 200: logger.error( @@ -56,7 +56,7 @@ class RealPython(commands.Cog): article_embed = Embed( title="Search results - Real Python", url=SEARCH_URL.format(user_search=quote_plus(user_search)), - description="Here are the top 5 results:", + description=f"Here are the top {max(5, len(articles))} results:", color=Colours.orange, ) -- cgit v1.2.3