From e629e7313d1b2f9814ddc5eb0a5c0b9ae91c2882 Mon Sep 17 00:00:00 2001 From: Michelle Date: Fri, 10 Apr 2026 14:34:06 +0200 Subject: [PATCH] add command to fetch and send random cat images --- main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.py b/main.py index d7072de..466b1c8 100644 --- a/main.py +++ b/main.py @@ -119,6 +119,19 @@ async def setChannel(message): async def version(message): await message.channel.send("Version 0.3 is running") +# the cat bot died, so i wanted to add this command to this bot +@bot.command() +async def cat(message): + response = requests.get("https://api.thecatapi.com/v1/images/search") + if response.status_code == 200: + data = response.json() + if data and isinstance(data, list) and "url" in data[0]: + await message.channel.send(data[0]["url"]) + else: + await message.channel.send("Could not fetch cat image") + else: + await message.channel.send("Failed to fetch cat image") + async def post_reddit(): subreddit = os.getenv("SUBREDDIT", "ich_iel") posts = await get_latest_post(subreddit)