diff options
| author | 2022-09-18 22:03:34 +0100 | |
|---|---|---|
| committer | 2022-09-18 22:03:34 +0100 | |
| commit | 46d1e8ddb217f1bb5e07179b32db50b6a04b6de8 (patch) | |
| tree | c3f4db63c2751c51acfee97d016551b8f677e29b /bot/exts/utilities/realpython.py | |
| parent | Remove unnecessary hasattr check (diff) | |
| parent | Fix Poetry 1.2 Support (#1099) (diff) | |
Merge branch 'main' into fix-whitelist-inheritance
Diffstat (limited to 'bot/exts/utilities/realpython.py')
| -rw-r--r-- | bot/exts/utilities/realpython.py | 16 | 
1 files changed, 12 insertions, 4 deletions
| diff --git a/bot/exts/utilities/realpython.py b/bot/exts/utilities/realpython.py index bf8f1341..5e9757d0 100644 --- a/bot/exts/utilities/realpython.py +++ b/bot/exts/utilities/realpython.py @@ -11,11 +11,10 @@ from bot.constants import Colours  logger = logging.getLogger(__name__) -  API_ROOT = "https://realpython.com/search/api/v1/"  ARTICLE_URL = "https://realpython.com{article_url}"  SEARCH_URL = "https://realpython.com/search?q={user_search}" - +HOME_URL = "https://realpython.com/"  ERROR_EMBED = Embed(      title="Error while searching Real Python", @@ -32,13 +31,22 @@ class RealPython(commands.Cog):      @commands.command(aliases=["rp"])      @commands.cooldown(1, 10, commands.cooldowns.BucketType.user) -    async def realpython(self, ctx: commands.Context, amount: Optional[int] = 5, *, user_search: str) -> None: +    async def realpython(self, ctx: commands.Context, amount: Optional[int] = 5, *, +                         user_search: Optional[str] = None) -> None:          """          Send some articles from RealPython that match the search terms. -        By default the top 5 matches are sent, this can be overwritten to +        By default, the top 5 matches are sent. This can be overwritten to          a number between 1 and 5 by specifying an amount before the search query. +        If no search query is specified by the user, the home page is sent.          """ +        if user_search is None: +            home_page_embed = Embed(title="Real Python Home Page", url=HOME_URL, colour=Colours.orange) + +            await ctx.send(embed=home_page_embed) + +            return +          if not 1 <= amount <= 5:              await ctx.send("`amount` must be between 1 and 5 (inclusive).")              return | 
