diff options
author | 2021-08-30 22:14:33 -0400 | |
---|---|---|
committer | 2021-08-30 22:14:33 -0400 | |
commit | 491ae8c2e8f2afde1b3f9c928684ef2170f17551 (patch) | |
tree | 9e72b994fe8e4526652b81f94979c9eced5f83a6 /bot/exts/evergreen/status_codes.py | |
parent | Update branch with main (diff) |
Add requested changes
Now that the branch is correctly tracking only the changes to the
file `status_codes.py` the other requests can be addressed. Currently
the only change not addressed is to handle the range of responses
allowed. My focus will be on lines 45 to 64 for these changes.
Issues #428 #500 #608
PR #610
Diffstat (limited to 'bot/exts/evergreen/status_codes.py')
-rw-r--r-- | bot/exts/evergreen/status_codes.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/bot/exts/evergreen/status_codes.py b/bot/exts/evergreen/status_codes.py index 7f6d160d..2395f581 100644 --- a/bot/exts/evergreen/status_codes.py +++ b/bot/exts/evergreen/status_codes.py @@ -7,9 +7,9 @@ from bot.bot import Bot HTTP_DOG_URL = "https://httpstatusdogs.com/img/{code}.jpg" HTTP_CAT_URL = "https://http.cat/{code}.jpg" -STATUS_TEMPLATE = '**Status: {code}**' -ERR_404 = 'Unable to find status Floof for {code}.' -ERR_UNKNOWN = 'Error attempting to retrieve status Floof for {code}.' +STATUS_TEMPLATE = "**Status: {code}**" +ERR_404 = "Unable to find status Floof for {code}." +ERR_UNKNOWN = "Error attempting to retrieve status Floof for {code}." class HTTPStatusCodes(commands.Cog): @@ -22,7 +22,11 @@ class HTTPStatusCodes(commands.Cog): def __init__(self, bot: Bot): self.bot = bot - @commands.group(name="http_status", aliases=("status", "httpstatus"), invoke_without_command=True) + @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)) @@ -42,15 +46,23 @@ class HTTPStatusCodes(commands.Cog): """Attempt to build and dispatch embed. Append error message instead if something goes wrong.""" async with self.bot.http_session.get(url, allow_redirects=False) as response: if 200 <= response.status <= 299: - await ctx.send(embed=discord.Embed( - title=STATUS_TEMPLATE.format(code=code)).set_image(url=url)) + await ctx.send( + embed=discord.Embed( + title=STATUS_TEMPLATE.format(code=code) + ).set_image(url=url) + ) elif 404 == response.status: - await ctx.send(embed=discord.Embed( - title=ERR_404.format(code=code)).set_image(url=url) + await ctx.send( + embed=discord.Embed(title=ERR_404.format(code=code)).set_image( + url=url + ) ) else: - await ctx.send(embed=discord.Embed( - title=STATUS_TEMPLATE.format(code=code), footer=ERR_UNKNOWN.format(code=code)) + await ctx.send( + embed=discord.Embed( + title=STATUS_TEMPLATE.format(code=code), + footer=ERR_UNKNOWN.format(code=code), + ) ) |