Refactor: Send URL of random teto image instead of the image file

This commit is contained in:
pancakes-proxy 2025-05-19 20:48:39 +09:00
parent 2f4e8ad721
commit fef13d2426

View File

@ -14,8 +14,15 @@ class RandomTeto(commands.Cog):
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
if resp.status == 200:
# Send the URL instead of the image file
await interaction.followup.send(url)
try:
data = await resp.json()
image_url = data.get("url")
if image_url:
await interaction.followup.send(image_url)
else:
await interaction.followup.send("No image URL found in response.", ephemeral=True)
except Exception:
await interaction.followup.send("Failed to parse server response.", ephemeral=True)
else:
await interaction.followup.send("Failed to fetch image.", ephemeral=True)