blob: e28b0213a2733daab872e269d1539320727043d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import logging
from discord.ext import commands
from http import HTTPStatus
import discord
log = logging.getLogger(__name__)
class StatusCats(commands.Cog):
"""Commands that give 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, code: int) -> None:
"""Sends an embed with an image of a cat, potraying the status code."""
embed = discord.Embed(title=f'**Status: {code}**')
embed.set_image(url=f'https://http.cat/{code}.jpg')
try:
HTTPStatus(code)
except ValueError:
embed.set_footer(text='Inputted status code does not exist.')
await ctx.send(embed=embed)
def setup(bot: commands.Bot) -> None:
"""Load the StatusCats cog."""
bot.add_cog(StatusCats(bot))
|