Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while used for discord bot #21

Open
mdxabu opened this issue Apr 16, 2024 · 0 comments
Open

Error while used for discord bot #21

mdxabu opened this issue Apr 16, 2024 · 0 comments

Comments

@mdxabu
Copy link

mdxabu commented Apr 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant