aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/status_codes.py
diff options
context:
space:
mode:
authorGravatar Chris <[email protected]>2021-05-16 15:27:58 +0100
committerGravatar Chris <[email protected]>2021-05-16 15:27:58 +0100
commit0585e210949ef808417d181579081416fa73fd18 (patch)
treed5f3a9102f420506f823ee9593857b4098d1af38 /bot/exts/evergreen/status_codes.py
parentChange authors value in pyproject.toml (diff)
parentSpring cleanup (#718) (diff)
Merge branch 'main' into pipenv-to-poetry
Diffstat (limited to 'bot/exts/evergreen/status_codes.py')
-rw-r--r--bot/exts/evergreen/status_codes.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/bot/exts/evergreen/status_codes.py b/bot/exts/evergreen/status_codes.py
index 874c87eb..a866692e 100644
--- a/bot/exts/evergreen/status_codes.py
+++ b/bot/exts/evergreen/status_codes.py
@@ -3,6 +3,9 @@ from http import HTTPStatus
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"
@@ -10,19 +13,19 @@ HTTP_CAT_URL = "https://http.cat/{code}.jpg"
class HTTPStatusCodes(commands.Cog):
"""Commands that give HTTP statuses described and visualized by cats and dogs."""
- def __init__(self, bot: commands.Bot):
+ 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 ctx.send_help(ctx.command)
+ await invoke_help_command(ctx)
- @http_status_group.command(name='cat')
+ @http_status_group.command(name="cat")
async def http_cat(self, ctx: commands.Context, code: int) -> None:
"""Sends an embed with an image of a cat, portraying the status code."""
- embed = discord.Embed(title=f'**Status: {code}**')
+ embed = discord.Embed(title=f"**Status: {code}**")
url = HTTP_CAT_URL.format(code=code)
try:
@@ -34,18 +37,18 @@ class HTTPStatusCodes(commands.Cog):
raise NotImplementedError
except ValueError:
- embed.set_footer(text='Inputted status code does not exist.')
+ embed.set_footer(text="Inputted status code does not exist.")
except NotImplementedError:
- embed.set_footer(text='Inputted status code is not implemented by http.cat yet.')
+ embed.set_footer(text="Inputted status code is not implemented by http.cat yet.")
finally:
await ctx.send(embed=embed)
- @http_status_group.command(name='dog')
+ @http_status_group.command(name="dog")
async def http_dog(self, ctx: commands.Context, code: int) -> None:
"""Sends an embed with an image of a dog, portraying the status code."""
- embed = discord.Embed(title=f'**Status: {code}**')
+ embed = discord.Embed(title=f"**Status: {code}**")
url = HTTP_DOG_URL.format(code=code)
try:
@@ -57,15 +60,15 @@ class HTTPStatusCodes(commands.Cog):
raise NotImplementedError
except ValueError:
- embed.set_footer(text='Inputted status code does not exist.')
+ embed.set_footer(text="Inputted status code does not exist.")
except NotImplementedError:
- embed.set_footer(text='Inputted status code is not implemented by httpstatusdogs.com yet.')
+ embed.set_footer(text="Inputted status code is not implemented by httpstatusdogs.com yet.")
finally:
await ctx.send(embed=embed)
-def setup(bot: commands.Bot) -> None:
+def setup(bot: Bot) -> None:
"""Load the HTTPStatusCodes cog."""
bot.add_cog(HTTPStatusCodes(bot))