artintel235 commited on
Commit
16cc397
·
verified ·
1 Parent(s): df4f8e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -80,13 +80,16 @@ async def generate_command(
80
  aspect_ratio: app_commands.Choice[str],
81
  ):
82
  """Generates an image based on the user's prompt and aspect ratio."""
 
 
83
  try:
84
- await interaction.response.defer() # MUST be the first await
 
85
 
86
- # Now it's safe to make other async calls:
87
  image_url_or_error = await generate_image_async(
88
  prompt, aspect_ratio.value
89
  )
 
90
 
91
  if image_url_or_error.startswith("http"):
92
  await interaction.followup.send(
@@ -97,9 +100,12 @@ async def generate_command(
97
  f"Sorry, I couldn't generate an image. {image_url_or_error}"
98
  )
99
 
 
 
100
  except Exception as e:
101
- print(f"An error occurred: {e}")
102
  await interaction.followup.send("An error occurred while processing your request.")
 
103
  @tree.command(name="hello", description="Says hello!")
104
  async def hello_command(interaction):
105
  await interaction.response.send_message("Hello there!")
 
80
  aspect_ratio: app_commands.Choice[str],
81
  ):
82
  """Generates an image based on the user's prompt and aspect ratio."""
83
+ print(f"Received /generate command from {interaction.user.name}") # Debug print
84
+
85
  try:
86
+ await interaction.response.defer(ephemeral=False) # Added ephemeral=False, visible to everyone
87
+ print("Interaction deferred") # Debug print
88
 
 
89
  image_url_or_error = await generate_image_async(
90
  prompt, aspect_ratio.value
91
  )
92
+ print(f"GLIF API response: {image_url_or_error}") # Debug print
93
 
94
  if image_url_or_error.startswith("http"):
95
  await interaction.followup.send(
 
100
  f"Sorry, I couldn't generate an image. {image_url_or_error}"
101
  )
102
 
103
+ print("Followup sent") # Debug print
104
+
105
  except Exception as e:
106
+ print(f"An error occurred: {e}") # More specific error
107
  await interaction.followup.send("An error occurred while processing your request.")
108
+
109
  @tree.command(name="hello", description="Says hello!")
110
  async def hello_command(interaction):
111
  await interaction.response.send_message("Hello there!")