import discord from discord.ext import commands import asyncio import requests _session = requests.Session() class Cat(commands.Cog): """Команда !cat — случайный котик""" @commands.command(name="cat") async def cat(self, ctx): """Получить случайного котика""" try: response = await asyncio.to_thread( _session.get, "https://api.thecatapi.com/v1/images/search", timeout=10 ) response.raise_for_status() data = response.json() url = data[0]["url"] embed = discord.Embed( title="🐱 Котик для тебя!", color=discord.Color.orange() ) embed.set_image(url=url) await ctx.send(embed=embed) except requests.exceptions.RequestException: await ctx.send("Не удалось получить котика. Попробуйте позже.")