[stable] agree, disagree, loading cleanup for consistency
Browse files
app.py
CHANGED
@@ -68,10 +68,8 @@ async def commands(ctx):
|
|
68 |
except Exception as e:
|
69 |
print(f"Error: unable to help :(")
|
70 |
#---------------------------------------------------------------------------------------------------------------------------------------------
|
71 |
-
async def safetychecks(ctx):
|
72 |
-
|
73 |
-
failure_emoji_id = 1098628957521313892
|
74 |
-
failure_emoji = discord.utils.get(emoji_guild.emojis, id=failure_emoji_id)
|
75 |
try:
|
76 |
if ctx.author.bot:
|
77 |
print(f"Error: The bot is not allowed to use its own commands.")
|
@@ -136,7 +134,7 @@ async def deepfloydifdemo(ctx):
|
|
136 |
await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113483403258499142/image.png')
|
137 |
except Exception as e:
|
138 |
print(f"Error: {e}")
|
139 |
-
await ctx.message.add_reaction('
|
140 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
141 |
@bot.command()
|
142 |
async def jojodemo(ctx):
|
@@ -147,7 +145,7 @@ async def jojodemo(ctx):
|
|
147 |
await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113492260294770778/image.png')
|
148 |
except Exception as e:
|
149 |
print(f"Error: {e}")
|
150 |
-
await ctx.message.add_reaction('
|
151 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
152 |
# jojo β
|
153 |
@bot.command()
|
@@ -175,16 +173,16 @@ async def jojo(ctx):
|
|
175 |
|
176 |
#testing animated
|
177 |
# <a:hugging_spin:1102656012621713488>
|
178 |
-
await ctx.message.add_reaction('
|
179 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
180 |
else: # no image
|
181 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
182 |
-
await ctx.message.add_reaction('
|
183 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
184 |
except Exception as e: # no generation / img + no face
|
185 |
print(f"Error: {e}")
|
186 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
187 |
-
await ctx.message.add_reaction('
|
188 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
189 |
|
190 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
@@ -193,7 +191,7 @@ async def jojo(ctx):
|
|
193 |
async def disney(ctx):
|
194 |
try:
|
195 |
if await safetychecks(ctx): #β
|
196 |
-
await ctx.message.add_reaction('
|
197 |
thread = await ctx.message.create_thread(name=f'{ctx.author} disney Thread')
|
198 |
if ctx.message.attachments:
|
199 |
await thread.send(f'{ctx.author.mention} Generating images in thread, can take ~1 minute...')
|
@@ -201,17 +199,17 @@ async def disney(ctx):
|
|
201 |
style = 'Disney'
|
202 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, 'disney')
|
203 |
await thread.send(f'{ctx.author.mention} Here is the {style} version of it', file=discord.File(im))
|
204 |
-
await ctx.message.add_reaction('
|
205 |
-
await ctx.message.remove_reaction('
|
206 |
else: # no image
|
207 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
208 |
-
await ctx.message.add_reaction('
|
209 |
-
await ctx.message.remove_reaction('
|
210 |
except Exception as e: # no generation / img + no face
|
211 |
print(f"Error: {e}")
|
212 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
213 |
-
await ctx.message.add_reaction('
|
214 |
-
await ctx.message.remove_reaction('
|
215 |
|
216 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
217 |
# Spider-Verse β
|
@@ -219,7 +217,7 @@ async def disney(ctx):
|
|
219 |
async def spidey(ctx):
|
220 |
try:
|
221 |
if await safetychecks(ctx): #β
|
222 |
-
await ctx.message.add_reaction('
|
223 |
thread = await ctx.message.create_thread(name=f'{ctx.author} spider-verse Thread')
|
224 |
if ctx.message.attachments:
|
225 |
await thread.send(f'{ctx.author.mention} Generating images in thread, can take ~1 minute...')
|
@@ -227,17 +225,17 @@ async def spidey(ctx):
|
|
227 |
style = 'Spider-Verse'
|
228 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
|
229 |
await thread.send(f'{ctx.author.mention} Here is the {style} version of it', file=discord.File(im))
|
230 |
-
await ctx.message.add_reaction('
|
231 |
-
await ctx.message.remove_reaction('
|
232 |
else: # no image
|
233 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
234 |
-
await ctx.message.add_reaction('
|
235 |
-
await ctx.message.remove_reaction('
|
236 |
except Exception as e: # no generation / img + no face
|
237 |
print(f"Error: {e}")
|
238 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
239 |
-
await ctx.message.add_reaction('
|
240 |
-
await ctx.message.remove_reaction('
|
241 |
|
242 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
243 |
# sketch β
|
@@ -245,7 +243,7 @@ async def spidey(ctx):
|
|
245 |
async def sketch(ctx):
|
246 |
try:
|
247 |
if await safetychecks(ctx): #β
|
248 |
-
await ctx.message.add_reaction('
|
249 |
thread = await ctx.message.create_thread(name=f'{ctx.author} sketch Thread')
|
250 |
if ctx.message.attachments:
|
251 |
await thread.send(f'{ctx.author.mention} Generating images in thread, can take ~1 minute...')
|
@@ -253,17 +251,17 @@ async def sketch(ctx):
|
|
253 |
#style = 'sketch'
|
254 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, 'sketch')
|
255 |
await thread.send(f'{ctx.author.mention} Here is the sketch version of it', file=discord.File(im))
|
256 |
-
await ctx.message.add_reaction('
|
257 |
-
await ctx.message.remove_reaction('
|
258 |
else: # no image
|
259 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
260 |
-
await ctx.message.add_reaction('
|
261 |
-
await ctx.message.remove_reaction('
|
262 |
except Exception as e: # no generation / img + no face
|
263 |
print(f"Error: {e}")
|
264 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
265 |
-
await ctx.message.add_reaction('
|
266 |
-
await ctx.message.remove_reaction('
|
267 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
268 |
# deepfloydif stage 1 generation β
|
269 |
def inference(prompt):
|
@@ -300,13 +298,10 @@ async def react1234(reaction_emojis, combined_image_dfif):
|
|
300 |
# Stage 1 β
|
301 |
@bot.command()
|
302 |
async def deepfloydif(ctx, *, prompt: str):
|
303 |
-
emoji_guild = ctx.guild
|
304 |
-
failure_emoji_id = 1098628957521313892
|
305 |
-
failure_emoji = discord.utils.get(emoji_guild.emojis, id=failure_emoji_id)
|
306 |
try:
|
307 |
try:
|
308 |
if await safetychecks(ctx): #β
|
309 |
-
await ctx.message.add_reaction('
|
310 |
dfif_command_message_id = ctx.message.id # we will use this in some magic later on
|
311 |
thread = await ctx.message.create_thread(name=f'{ctx.author} DeepfloydIF Image Upscaling Thread ')
|
312 |
# create thread -> send new message inside thread + combined_image -> add reactions -> dfif2
|
@@ -328,8 +323,8 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
328 |
print(f"Error: {e}")
|
329 |
thread = await ctx.message.create_thread(name=f'DFIF1 Error')
|
330 |
await thread.send(f"{ctx.author.mention} Error during stage 1 pre-generation.")
|
331 |
-
await ctx.message.remove_reaction('
|
332 |
-
await ctx.message.add_reaction(
|
333 |
|
334 |
#generationβ
-------------------------------------------------------
|
335 |
try:
|
@@ -350,8 +345,8 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
350 |
print(f"Error: {e}")
|
351 |
thread = await ctx.message.create_thread(name=f'Generation Error')
|
352 |
await thread.send(f"{ctx.author.mention} Error during stage 1 generation.")
|
353 |
-
await ctx.message.remove_reaction('
|
354 |
-
await ctx.message.add_reaction(
|
355 |
#posting imagesβ
----------------------------------------------------------------
|
356 |
try:
|
357 |
#await thread.send(f'β
combining images...')
|
@@ -408,16 +403,16 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
408 |
print(f"Error: {e}")
|
409 |
thread = await ctx.message.create_thread(name=f'Posting Error')
|
410 |
await thread.send(f"{ctx.author.mention} Encountered error while posting combined image in thread.")
|
411 |
-
await ctx.message.remove_reaction('
|
412 |
-
await ctx.message.add_reaction(
|
413 |
|
414 |
#deepfloydif try/except
|
415 |
except Exception as e:
|
416 |
print(f"Error: {e}")
|
417 |
thread = await ctx.message.create_thread(name=f'deepfloydif Error')
|
418 |
await thread.send(f"{ctx.author.mention} Overall error with deepfloydif.")
|
419 |
-
await ctx.message.remove_reaction('
|
420 |
-
await ctx.message.add_reaction(
|
421 |
|
422 |
#----------------------------------------------------------------------------------------------------------------------------
|
423 |
# Stage 2 β
|
@@ -448,8 +443,8 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
|
|
448 |
success_emoji = discord.utils.get(emoji_guild.emojis, id=success_emoji_id)
|
449 |
parent_channel = thread.parent
|
450 |
dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
|
451 |
-
await dfif_command_message.
|
452 |
-
await dfif_command_message.
|
453 |
|
454 |
except Exception as e:
|
455 |
print(f"Error: {e}")
|
@@ -459,8 +454,8 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
|
|
459 |
failure_emoji = discord.utils.get(emoji_guild.emojis, id=failure_emoji_id)
|
460 |
parent_channel = thread.parent
|
461 |
dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
|
462 |
-
await dfif_command_message.
|
463 |
-
await dfif_command_message.
|
464 |
await thread.send(f"Error during stage 2 upscaling.")
|
465 |
#----------------------------------------------------------------------------------------------------------------------------
|
466 |
# react detector for stage 2 β
|
|
|
68 |
except Exception as e:
|
69 |
print(f"Error: unable to help :(")
|
70 |
#---------------------------------------------------------------------------------------------------------------------------------------------
|
71 |
+
async def safetychecks(ctx):
|
72 |
+
failure_emoji = '<:disagree:1098628957521313892>'
|
|
|
|
|
73 |
try:
|
74 |
if ctx.author.bot:
|
75 |
print(f"Error: The bot is not allowed to use its own commands.")
|
|
|
134 |
await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113483403258499142/image.png')
|
135 |
except Exception as e:
|
136 |
print(f"Error: {e}")
|
137 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
138 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
139 |
@bot.command()
|
140 |
async def jojodemo(ctx):
|
|
|
145 |
await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113492260294770778/image.png')
|
146 |
except Exception as e:
|
147 |
print(f"Error: {e}")
|
148 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
149 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
150 |
# jojo β
|
151 |
@bot.command()
|
|
|
173 |
|
174 |
#testing animated
|
175 |
# <a:hugging_spin:1102656012621713488>
|
176 |
+
await ctx.message.add_reaction('<:agree:1098629085955113011>') # img + face
|
177 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
178 |
else: # no image
|
179 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
180 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
181 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
182 |
except Exception as e: # no generation / img + no face
|
183 |
print(f"Error: {e}")
|
184 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
185 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
186 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
187 |
|
188 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
191 |
async def disney(ctx):
|
192 |
try:
|
193 |
if await safetychecks(ctx): #β
|
194 |
+
await ctx.message.add_reaction('<a:loading:1114111677990981692>')
|
195 |
thread = await ctx.message.create_thread(name=f'{ctx.author} disney Thread')
|
196 |
if ctx.message.attachments:
|
197 |
await thread.send(f'{ctx.author.mention} Generating images in thread, can take ~1 minute...')
|
|
|
199 |
style = 'Disney'
|
200 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, 'disney')
|
201 |
await thread.send(f'{ctx.author.mention} Here is the {style} version of it', file=discord.File(im))
|
202 |
+
await ctx.message.add_reaction('<:agree:1098629085955113011>') # img + face
|
203 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
204 |
else: # no image
|
205 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
206 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
207 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
208 |
except Exception as e: # no generation / img + no face
|
209 |
print(f"Error: {e}")
|
210 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
211 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
212 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
213 |
|
214 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
215 |
# Spider-Verse β
|
|
|
217 |
async def spidey(ctx):
|
218 |
try:
|
219 |
if await safetychecks(ctx): #β
|
220 |
+
await ctx.message.add_reaction('<a:loading:1114111677990981692>')
|
221 |
thread = await ctx.message.create_thread(name=f'{ctx.author} spider-verse Thread')
|
222 |
if ctx.message.attachments:
|
223 |
await thread.send(f'{ctx.author.mention} Generating images in thread, can take ~1 minute...')
|
|
|
225 |
style = 'Spider-Verse'
|
226 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
|
227 |
await thread.send(f'{ctx.author.mention} Here is the {style} version of it', file=discord.File(im))
|
228 |
+
await ctx.message.add_reaction('<:agree:1098629085955113011>') # img + face
|
229 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
230 |
else: # no image
|
231 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
232 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
233 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
234 |
except Exception as e: # no generation / img + no face
|
235 |
print(f"Error: {e}")
|
236 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
237 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
238 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
239 |
|
240 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
241 |
# sketch β
|
|
|
243 |
async def sketch(ctx):
|
244 |
try:
|
245 |
if await safetychecks(ctx): #β
|
246 |
+
await ctx.message.add_reaction('<a:loading:1114111677990981692>')
|
247 |
thread = await ctx.message.create_thread(name=f'{ctx.author} sketch Thread')
|
248 |
if ctx.message.attachments:
|
249 |
await thread.send(f'{ctx.author.mention} Generating images in thread, can take ~1 minute...')
|
|
|
251 |
#style = 'sketch'
|
252 |
im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, 'sketch')
|
253 |
await thread.send(f'{ctx.author.mention} Here is the sketch version of it', file=discord.File(im))
|
254 |
+
await ctx.message.add_reaction('<:agree:1098629085955113011>') # img + face
|
255 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
256 |
else: # no image
|
257 |
await thread.send(f"{ctx.author.mention} No attachments to be found...Can't animify dat! Try sending me an image π")
|
258 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
259 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
260 |
except Exception as e: # no generation / img + no face
|
261 |
print(f"Error: {e}")
|
262 |
await thread.send(f"{ctx.author.mention} Error: {e}")
|
263 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
264 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
265 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
266 |
# deepfloydif stage 1 generation β
|
267 |
def inference(prompt):
|
|
|
298 |
# Stage 1 β
|
299 |
@bot.command()
|
300 |
async def deepfloydif(ctx, *, prompt: str):
|
|
|
|
|
|
|
301 |
try:
|
302 |
try:
|
303 |
if await safetychecks(ctx): #β
|
304 |
+
await ctx.message.add_reaction('<a:loading:1114111677990981692>')
|
305 |
dfif_command_message_id = ctx.message.id # we will use this in some magic later on
|
306 |
thread = await ctx.message.create_thread(name=f'{ctx.author} DeepfloydIF Image Upscaling Thread ')
|
307 |
# create thread -> send new message inside thread + combined_image -> add reactions -> dfif2
|
|
|
323 |
print(f"Error: {e}")
|
324 |
thread = await ctx.message.create_thread(name=f'DFIF1 Error')
|
325 |
await thread.send(f"{ctx.author.mention} Error during stage 1 pre-generation.")
|
326 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
327 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
328 |
|
329 |
#generationβ
-------------------------------------------------------
|
330 |
try:
|
|
|
345 |
print(f"Error: {e}")
|
346 |
thread = await ctx.message.create_thread(name=f'Generation Error')
|
347 |
await thread.send(f"{ctx.author.mention} Error during stage 1 generation.")
|
348 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
349 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
350 |
#posting imagesβ
----------------------------------------------------------------
|
351 |
try:
|
352 |
#await thread.send(f'β
combining images...')
|
|
|
403 |
print(f"Error: {e}")
|
404 |
thread = await ctx.message.create_thread(name=f'Posting Error')
|
405 |
await thread.send(f"{ctx.author.mention} Encountered error while posting combined image in thread.")
|
406 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
407 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
408 |
|
409 |
#deepfloydif try/except
|
410 |
except Exception as e:
|
411 |
print(f"Error: {e}")
|
412 |
thread = await ctx.message.create_thread(name=f'deepfloydif Error')
|
413 |
await thread.send(f"{ctx.author.mention} Overall error with deepfloydif.")
|
414 |
+
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
415 |
+
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
416 |
|
417 |
#----------------------------------------------------------------------------------------------------------------------------
|
418 |
# Stage 2 β
|
|
|
443 |
success_emoji = discord.utils.get(emoji_guild.emojis, id=success_emoji_id)
|
444 |
parent_channel = thread.parent
|
445 |
dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
|
446 |
+
await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
447 |
+
await dfif_command_message.add_reaction('<:agree:1098629085955113011>')
|
448 |
|
449 |
except Exception as e:
|
450 |
print(f"Error: {e}")
|
|
|
454 |
failure_emoji = discord.utils.get(emoji_guild.emojis, id=failure_emoji_id)
|
455 |
parent_channel = thread.parent
|
456 |
dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
|
457 |
+
await dfif_command_message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
458 |
+
await dfif_command_message.add_reaction('<:disagree:1098628957521313892>')
|
459 |
await thread.send(f"Error during stage 2 upscaling.")
|
460 |
#----------------------------------------------------------------------------------------------------------------------------
|
461 |
# react detector for stage 2 β
|