Skip to content

Error while used for discord bot  #21

Open
@mdxabu

Description

@mdxabu

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:

image

If i print in console it works well, but doesn't send img to discord

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions