aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar brad90four <[email protected]>2021-08-31 14:20:52 -0400
committerGravatar brad90four <[email protected]>2021-08-31 14:20:52 -0400
commit628bd9dfcc50e3cedb8a38c9915f89fcce2c2564 (patch)
treefe8121ced4f4c90f7bf6f942c67433fb4ded13ce
parentAdd returns after sending embed (diff)
Fix Dog instead of Cat, code error embed update
Corrected the URL for the Dog embed (was mistakenly using CAT URL. Created a standalone ERROR_LENGTH_EMBED to send if the code used by the user is not in the range 100, 599. Changed the response status check to include 299 (to be proper).
-rw-r--r--bot/exts/evergreen/status_codes.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/bot/exts/evergreen/status_codes.py b/bot/exts/evergreen/status_codes.py
index 53d7b964..56cc5786 100644
--- a/bot/exts/evergreen/status_codes.py
+++ b/bot/exts/evergreen/status_codes.py
@@ -10,6 +10,10 @@ 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}."
+ERROR_LENGTH_EMBED = discord.Embed(
+ title="Input status code does not exist",
+ description="The range of valid status codes is 100 to 599",
+)
class HTTPStatusCodes(commands.Cog):
@@ -38,30 +42,20 @@ class HTTPStatusCodes(commands.Cog):
if code in range(100, 599):
await self.build_embed(url=HTTP_CAT_URL.format(code=code), ctx=ctx, code=code)
return
- await ctx.send(
- embed=discord.Embed(
- title="Input status code does not exist",
- description="The range of accepted status codes that are ok is from 100 to 599",
- )
- )
+ await ctx.send(embed=ERROR_LENGTH_EMBED)
@http_status_group.command(name="dog")
async def http_dog(self, ctx: commands.Context, code: int) -> None:
"""Send a dog version of the requested HTTP status code."""
if code in range(100, 599):
- await self.build_embed(url=HTTP_CAT_URL.format(code=code), ctx=ctx, code=code)
+ await self.build_embed(url=HTTP_DOG_URL.format(code=code), ctx=ctx, code=code)
return
- await ctx.send(
- embed=discord.Embed(
- title="Input status code does not exist",
- description="The range of accepted status codes that are ok is from 100 to 599",
- )
- )
+ await ctx.send(embed=ERROR_LENGTH_EMBED)
async def build_embed(self, url: str, ctx: commands.Context, code: int) -> None:
"""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 response.status in range(200, 299):
+ if response.status in range(200, 300):
await ctx.send(
embed=discord.Embed(
title=STATUS_TEMPLATE.format(code=code)