29 lines
932 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import discord
from discord.ext import commands
import requests
class Cat(commands.Cog):
"""Команда !cat — случайный котик"""
@commands.command(name="cat")
async def cat(self, ctx):
"""Получить случайного котика"""
try:
response = requests.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.RequestException:
await ctx.send("Не удалось получить котика. Попробуйте позже.")