diff options
| author | 2020-09-18 23:01:42 +0800 | |
|---|---|---|
| committer | 2020-09-18 23:01:42 +0800 | |
| commit | 636cda284a5a2c2f51a17e87c8b71c0f6edcfb22 (patch) | |
| tree | 3523b6eb11f5d752f9060dfba18dbd68a14ac1b0 /bot/exts/evergreen/status_cats.py | |
| parent | Fix typo in casercipher help. (diff) | |
| parent | Merge pull request #442 from python-discord/reddit-command-fix (diff) | |
Merge branch 'master' into caesar-command
Diffstat (limited to 'bot/exts/evergreen/status_cats.py')
| -rw-r--r-- | bot/exts/evergreen/status_cats.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bot/exts/evergreen/status_cats.py b/bot/exts/evergreen/status_cats.py new file mode 100644 index 00000000..586b8378 --- /dev/null +++ b/bot/exts/evergreen/status_cats.py @@ -0,0 +1,33 @@ +from http import HTTPStatus + +import discord +from discord.ext import commands + + +class StatusCats(commands.Cog): + """Commands that give HTTP statuses described and visualized by cats.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.command(aliases=['statuscat']) + async def http_cat(self, ctx: commands.Context, code: int) -> None: + """Sends an embed with an image of a cat, potraying the status code.""" + embed = discord.Embed(title=f'**Status: {code}**') + + try: + HTTPStatus(code) + + except ValueError: + embed.set_footer(text='Inputted status code does not exist.') + + else: + embed.set_image(url=f'https://http.cat/{code}.jpg') + + finally: + await ctx.send(embed=embed) + + +def setup(bot: commands.Bot) -> None: + """Load the StatusCats cog.""" + bot.add_cog(StatusCats(bot)) |