ARgh!
This commit is contained in:
parent
c5d36a2905
commit
3d12dae65d
@ -8,6 +8,7 @@ import base64
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import tempfile
|
||||||
from redbot.core import Config, commands
|
from redbot.core import Config, commands
|
||||||
|
|
||||||
|
|
||||||
@ -135,9 +136,10 @@ class ReginaldCog(commands.Cog):
|
|||||||
async with session.get(image_url) as resp:
|
async with session.get(image_url) as resp:
|
||||||
image_data = await resp.read()
|
image_data = await resp.read()
|
||||||
image = Image.open(BytesIO(image_data))
|
image = Image.open(BytesIO(image_data))
|
||||||
image.save("image.png")
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
await ctx.send(file=discord.File("image.png"))
|
image_path = os.path.join(temp_dir, "image.png")
|
||||||
os.remove("image.png")
|
image.save(image_path)
|
||||||
|
await ctx.send(file=discord.File(image_path))
|
||||||
else:
|
else:
|
||||||
await ctx.author.send("I apologize, but I am unable to generate an image based on the provided prompt.")
|
await ctx.author.send("I apologize, but I am unable to generate an image based on the provided prompt.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user