aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar sam-heller <[email protected]>2021-03-03 07:14:53 -0500
committerGravatar sam-heller <[email protected]>2021-03-03 07:16:01 -0500
commitc91ae2d6aaffbde168ab85e35ff3ad7ce6dedda2 (patch)
tree882c0da1ccc906a9ae8f4a9af90e3808d4a67307
parentMerge remote-tracking branch 'origin/teapot-support' into teapot-support (diff)
Return 404 Floof embed on invalid status code
-rw-r--r--bot/exts/evergreen/status_codes.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/bot/exts/evergreen/status_codes.py b/bot/exts/evergreen/status_codes.py
index 231d0254..91eaa988 100644
--- a/bot/exts/evergreen/status_codes.py
+++ b/bot/exts/evergreen/status_codes.py
@@ -31,15 +31,23 @@ class HTTPStatusCodes(Cog):
await self.build_embed(url=HTTP_DOG_URL.format(code), ctx=ctx, code=code)
async def build_embed(self, url: str, code: int, ctx: Context, ) -> None:
- """Attempt to build and dispatch embed. Append error message instead of something goes wrong."""
+ """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), url=url))
+ await ctx.send(embed=discord.Embed(
+ title=STATUS_TEMPLATE.format(code),
+ url=url
+ ))
+ elif 404 == response.status:
+ await ctx.send(embed=discord.Embed(
+ title=ERR_404.format(code),
+ url=url
+ ))
else:
await ctx.send(embed=discord.Embed(
title=STATUS_TEMPLATE.format(code),
- footer=ERR_404.format(code) if response.status == 404 else ERR_UNKNOWN.format(code))
- )
+ footer=ERR_UNKNOWN.format(code)
+ ))
def setup(bot: Bot) -> None: