diff options
author | 2021-08-30 20:36:07 +0100 | |
---|---|---|
committer | 2021-08-30 20:36:07 +0100 | |
commit | 7aaf8f406fcb6cbe89e4b6742eff6c3efa754993 (patch) | |
tree | 7f759a49efc57c3b2ffc1396fc151bada42217e1 | |
parent | Merge pull request #814 from python-discord/coinflip-command (diff) | |
parent | Handle single article result (diff) |
Merge pull request #831 from brad90four/patch-1
Only send articles to user - Closes Issue#828
-rw-r--r-- | bot/exts/evergreen/realpython.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bot/exts/evergreen/realpython.py b/bot/exts/evergreen/realpython.py index e722dd4b..5d9e5c5c 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( @@ -53,10 +53,15 @@ class RealPython(commands.Cog): await ctx.send(embed=no_articles) return + if len(articles) == 1: + article_description = "Here is the result:" + else: + article_description = f"Here are the top {len(articles)} results:" + 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=article_description, color=Colours.orange, ) |