check marks / failure reactions for more responsiveness
Browse files
app.py
CHANGED
|
@@ -56,9 +56,9 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
| 56 |
return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
|
| 57 |
|
| 58 |
await ctx.message.add_reaction('👍')
|
| 59 |
-
thread = await ctx.message.create_thread(name=f'Image Upscaling Thread
|
| 60 |
# create thread -> send new message inside thread + combined_image -> add reactions -> dfif2
|
| 61 |
-
await thread.send(f'
|
| 62 |
|
| 63 |
number_of_images = 4
|
| 64 |
current_time = int(time.time())
|
|
@@ -114,7 +114,7 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
| 114 |
|
| 115 |
#4
|
| 116 |
with open(combined_image_path, 'rb') as f:
|
| 117 |
-
threadmsg = await thread.send(f'
|
| 118 |
|
| 119 |
# bot reacts with appropriate emojis to the post, both showing the user what options they have,
|
| 120 |
# as well as showing which post to react to.
|
|
@@ -123,19 +123,19 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
| 123 |
|
| 124 |
reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
|
| 125 |
if str(reaction.emoji) == '1️⃣':
|
| 126 |
-
await thread.send(f"Upscaling the first image...
|
| 127 |
index = 0
|
| 128 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 129 |
elif str(reaction.emoji) == '2️⃣':
|
| 130 |
-
await thread.send(f"Upscaling the second image...
|
| 131 |
index = 1
|
| 132 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 133 |
elif str(reaction.emoji) == '3️⃣':
|
| 134 |
-
await thread.send(f"Upscaling the third image...
|
| 135 |
index = 2
|
| 136 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 137 |
elif str(reaction.emoji) == '4️⃣':
|
| 138 |
-
await thread.send(f"Upscaling the fourth image...
|
| 139 |
index = 3
|
| 140 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 141 |
|
|
@@ -143,6 +143,7 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
| 143 |
except Exception as e:
|
| 144 |
print(f"Error: {e}")
|
| 145 |
await ctx.reply('An error occurred while processing your request. Please wait 5 seconds before retrying.')
|
|
|
|
| 146 |
|
| 147 |
#----------------------------------------------------------------------------------------------------------------------------
|
| 148 |
# Stage 2
|
|
@@ -158,12 +159,17 @@ async def dfif2(ctx, index: int, stage_1_result_path, thread):
|
|
| 158 |
|
| 159 |
|
| 160 |
with open(result_path, 'rb') as f:
|
| 161 |
-
await thread.send(f'Here is the
|
| 162 |
#await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
except Exception as e:
|
| 165 |
print(f"Error: {e}")
|
| 166 |
await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
|
|
|
|
| 167 |
#----------------------------------------------------------------------------------------------------------------------------
|
| 168 |
|
| 169 |
|
|
|
|
| 56 |
return user == ctx.author and str(reaction.emoji) in ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
|
| 57 |
|
| 58 |
await ctx.message.add_reaction('👍')
|
| 59 |
+
thread = await ctx.message.create_thread(name=f'{ctx.author.} Image Upscaling Thread ')
|
| 60 |
# create thread -> send new message inside thread + combined_image -> add reactions -> dfif2
|
| 61 |
+
await thread.send(f'{ctx.author.mention}Generating images in thread, can take ~1 minute...')
|
| 62 |
|
| 63 |
number_of_images = 4
|
| 64 |
current_time = int(time.time())
|
|
|
|
| 114 |
|
| 115 |
#4
|
| 116 |
with open(combined_image_path, 'rb') as f:
|
| 117 |
+
threadmsg = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale!', file=discord.File(f, 'combined_image.png'))
|
| 118 |
|
| 119 |
# bot reacts with appropriate emojis to the post, both showing the user what options they have,
|
| 120 |
# as well as showing which post to react to.
|
|
|
|
| 123 |
|
| 124 |
reaction, user = await bot.wait_for('reaction_add', check=check_reaction)
|
| 125 |
if str(reaction.emoji) == '1️⃣':
|
| 126 |
+
await thread.send(f"{ctx.author.mention}Upscaling the first image...")
|
| 127 |
index = 0
|
| 128 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 129 |
elif str(reaction.emoji) == '2️⃣':
|
| 130 |
+
await thread.send(f"{ctx.author.mention}Upscaling the second image...")
|
| 131 |
index = 1
|
| 132 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 133 |
elif str(reaction.emoji) == '3️⃣':
|
| 134 |
+
await thread.send(f"{ctx.author.mention}Upscaling the third image...")
|
| 135 |
index = 2
|
| 136 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 137 |
elif str(reaction.emoji) == '4️⃣':
|
| 138 |
+
await thread.send(f"{ctx.author.mention}Upscaling the fourth image...")
|
| 139 |
index = 3
|
| 140 |
await dfif2(ctx, index, stage_1_result_path, thread)
|
| 141 |
|
|
|
|
| 143 |
except Exception as e:
|
| 144 |
print(f"Error: {e}")
|
| 145 |
await ctx.reply('An error occurred while processing your request. Please wait 5 seconds before retrying.')
|
| 146 |
+
await ctx.message.add_reaction('❌')
|
| 147 |
|
| 148 |
#----------------------------------------------------------------------------------------------------------------------------
|
| 149 |
# Stage 2
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
with open(result_path, 'rb') as f:
|
| 162 |
+
await thread.send(f'{ctx.author.mention}Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
|
| 163 |
#await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
|
| 164 |
+
await ctx.message.add_reaction('✔️')
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
|
| 169 |
except Exception as e:
|
| 170 |
print(f"Error: {e}")
|
| 171 |
await ctx.reply('An error occurred while processing stage 2 upscaling. Please try again later.')
|
| 172 |
+
await ctx.message.add_reaction('❌')
|
| 173 |
#----------------------------------------------------------------------------------------------------------------------------
|
| 174 |
|
| 175 |
|