|
7 | 7 | import json |
8 | 8 | from datetime import datetime, timedelta |
9 | 9 | import time |
| 10 | +import asyncio |
10 | 11 |
|
11 | 12 | load_dotenv(override=True) |
12 | 13 |
|
@@ -526,9 +527,12 @@ async def send(interaction: discord.Interaction, prompt: str, img_dimensions: st |
526 | 527 | return |
527 | 528 | else: |
528 | 529 | img_style = img_style.lower() |
| 530 | + |
| 531 | + loop = asyncio.get_event_loop() |
| 532 | + image_url = await loop.run_in_executor(None, dalle3, prompt, img_quality, img_dimensions, img_style) |
529 | 533 |
|
530 | 534 | # Send as followup message |
531 | | - await interaction.followup.send(f"{dalle3(prompt, img_quality, img_dimensions, img_style)} IMAGE LINK EXPIRES IN <t:{int(time.mktime(future_time.timetuple()))}:R>") |
| 535 | + await interaction.followup.send(f"{image_url} IMAGE LINK EXPIRES IN <t:{int(time.mktime(future_time.timetuple()))}:R>") |
532 | 536 | except Exception as e: |
533 | 537 | # Handle exceptions |
534 | 538 | print(f"An error occurred: {str(e)}") |
@@ -559,9 +563,12 @@ async def send(interaction: discord.Interaction, prompt: str, img_dimensions: st |
559 | 563 | return |
560 | 564 | else: |
561 | 565 | img_dimensions = img_dimensions.lower() |
| 566 | + |
| 567 | + loop = asyncio.get_event_loop() |
| 568 | + image_url = await loop.run_in_executor(None, dalle2, prompt, img_dimensions) |
562 | 569 |
|
563 | 570 | # Send as followup message |
564 | | - await interaction.followup.send(f"{dalle2(prompt, img_dimensions)} IMAGE LINK EXPIRES IN <t:{int(time.mktime(future_time.timetuple()))}:R>") # Convert future_time to unix timestamp. |
| 571 | + await interaction.followup.send(f"{image_url} IMAGE LINK EXPIRES IN <t:{int(time.mktime(future_time.timetuple()))}:R>") # Convert future_time to unix timestamp. |
565 | 572 | except Exception as e: |
566 | 573 | # Handle exceptions |
567 | 574 | print(f"An error occurred: {str(e)}") |
|
0 commit comments