aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-05-19 23:31:21 +0100
committerGravatar GitHub <[email protected]>2021-05-19 23:31:21 +0100
commitf3d45db2e4c6d466a4de48504a608dd2e9a91e66 (patch)
treec83c50f3342c1cb6141915c455ce1963e837bf5e /bot
parentMerge pull request #744 from python-discord/remove-superfluous-dependencies (diff)
parentMerge branch 'main' into http_status_command_randomness (diff)
Merge pull request #733 from Icebluewolf/http_status_command_randomness
Http status command randomness
Diffstat (limited to 'bot')
-rw-r--r--bot/exts/evergreen/status_codes.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/bot/exts/evergreen/status_codes.py b/bot/exts/evergreen/status_codes.py
index a866692e..089bdb4a 100644
--- a/bot/exts/evergreen/status_codes.py
+++ b/bot/exts/evergreen/status_codes.py
@@ -1,26 +1,30 @@
from http import HTTPStatus
+from random import choice
import discord
from discord.ext import commands
from bot.bot import Bot
-from bot.utils.extensions import invoke_help_command
HTTP_DOG_URL = "https://httpstatusdogs.com/img/{code}.jpg"
HTTP_CAT_URL = "https://http.cat/{code}.jpg"
class HTTPStatusCodes(commands.Cog):
- """Commands that give HTTP statuses described and visualized by cats and dogs."""
+ """
+ Fetch an image depicting HTTP status codes as a dog or a cat.
+
+ If neither animal is selected a cat or dog is chosen randomly for the given status code.
+ """
def __init__(self, bot: Bot):
self.bot = bot
- @commands.group(name="http_status", aliases=("status", "httpstatus"))
- async def http_status_group(self, ctx: commands.Context) -> None:
- """Group containing dog and cat http status code commands."""
- if not ctx.invoked_subcommand:
- await invoke_help_command(ctx)
+ @commands.group(name="http_status", aliases=("status", "httpstatus"), invoke_without_command=True)
+ async def http_status_group(self, ctx: commands.Context, code: int) -> None:
+ """Choose a cat or dog randomly for the given status code."""
+ subcmd = choice((self.http_cat, self.http_dog))
+ await subcmd(ctx, code)
@http_status_group.command(name="cat")
async def http_cat(self, ctx: commands.Context, code: int) -> None: