aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/realpython.py
diff options
context:
space:
mode:
authorGravatar brad90four <[email protected]>2021-08-30 12:13:29 -0400
committerGravatar GitHub <[email protected]>2021-08-30 12:13:29 -0400
commit397605b14ecb0262d3dfa904a1661eb2514a1d5e (patch)
treed6a1751533b077216b248ac312bf66b9c4d67a95 /bot/exts/evergreen/realpython.py
parentMerge pull request #814 from python-discord/coinflip-command (diff)
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]
Diffstat (limited to 'bot/exts/evergreen/realpython.py')
-rw-r--r--bot/exts/evergreen/realpython.py4
1 files changed, 2 insertions, 2 deletions
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,
)