12 lines
570 B
Python
12 lines
570 B
Python
import io,time
|
|
import aiohttp,discord
|
|
from discord.ext import commands
|
|
class cat(commands.Cog):
|
|
def __init__(s,bot):s.bot=bot
|
|
@commands.command()
|
|
async def cat(s,ctx):
|
|
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=15)) as http,http.get("https://cataas.com/cat") as r:
|
|
r.raise_for_status();data=await r.read();ext=r.content_type.split('/')[-1].replace('jpeg','jpg')
|
|
await ctx.send(file=discord.File(io.BytesIO(data),filename=f"cat-{int(time.time())}.{ext}"))
|
|
async def setup(bot):await bot.add_cog(cat(bot))
|