Error while used for discord bot
mdxabu opened this issue · 0 comments
mdxabu commented
Code:
@app_commands.command(name="texttoimg",description="Give your prompt to generate image")
async def texttoimg(self,interaction: discord.Interaction,prompt: str):
# await interaction.response.send_message("Generating: "+prompt+" ....")
generator = Craiyon()
generated_images = await generator.async_generate(prompt)
b64_list = await craiyon_utils.async_encode_base64(generated_images.images)
images1 = []
for index, image in enumerate(b64_list):
img_bytes = BytesIO(base64.b64decode(image))
# image = discord.File(img_bytes)
image = discord.File(img_bytes)
image.filename = f"result{index}.webp"
images1.append(image)
await interaction.response.send_message(files=images1)
Output:
If i print in console it works well, but doesn't send img to discord