Rifat Azad commited on
Commit
b975879
·
1 Parent(s): fc8a2ef

possible fix

Browse files
Files changed (1) hide show
  1. pydvpl_bot.py +11 -13
pydvpl_bot.py CHANGED
@@ -569,22 +569,20 @@ async def image(ctx, *, prompt: str):
569
 
570
  await ctx.send(f"Generating prompt `{prompt}` please be patient...")
571
 
572
- try:
573
- generator = Craiyon()
574
- generated_images = await generator.async_generate(prompt) # Generate images
575
- b64_list = await craiyon_utils.async_encode_base64(generated_images.images) # Download images from https://img.craiyon.com and store them as b64 bytestring object
576
 
577
- images1 = []
578
- for index, image in enumerate(b64_list): # Loop through b64_list, keeping track of the index
579
- img_bytes = BytesIO(base64.b64decode(image)) # Decode the image and store it as a bytes object
580
- image = discord.File(img_bytes)
581
- image.filename = f"result{index}.webp"
582
- images1.append(image) # Add the image to the images1 list
583
 
584
- await ctx.reply(files=images1) # Reply to the user with all 9 images in 1 message
 
 
 
 
 
 
 
585
 
586
- except Exception as e:
587
- await ctx.send(f"An error occurred while generating prompt `{prompt}`: {e}")
588
 
589
 
590
  # UTILITY USER_CMD ------------------------------------------------------ END
 
569
 
570
  await ctx.send(f"Generating prompt `{prompt}` please be patient...")
571
 
 
 
 
 
572
 
573
+ generator = Craiyon()
574
+ generated_images = await generator.async_generate(prompt) # Generate images
575
+ b64_list = await craiyon_utils.async_encode_base64(generated_images.images) # Download images from https://img.craiyon.com and store them as b64 bytestring object
 
 
 
576
 
577
+ images1 = []
578
+ for index, image in enumerate(b64_list): # Loop through b64_list, keeping track of the index
579
+ img_bytes = BytesIO(base64.b64decode(image)) # Decode the image and store it as a bytes object
580
+ image = discord.File(img_bytes)
581
+ image.filename = f"result{index}.webp"
582
+ images1.append(image) # Add the image to the images1 list
583
+
584
+ await ctx.reply(files=images1) # Reply to the user with all 9 images in 1 message
585
 
 
 
586
 
587
 
588
  # UTILITY USER_CMD ------------------------------------------------------ END