lunarflu HF Staff commited on
Commit
3ad6f29
·
1 Parent(s): ed27d58

⏳ remove painter, spaces for demos, spacing for messages, removed 🤖, numbers -> arrows, animated react test

Browse files
Files changed (1) hide show
  1. app.py +36 -34
app.py CHANGED
@@ -131,7 +131,7 @@ async def safetychecks(ctx):
131
  async def deepfloydifdemo(ctx):
132
  try:
133
  thread = await ctx.message.create_thread(name=f'{ctx.author} Demo Thread')
134
- await thread.send(f'{ctx.author.mention}Here is a demo for the !deepfloydif command!')
135
  await asyncio.sleep(0.5)
136
  await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113483403258499142/image.png')
137
  except Exception as e:
@@ -142,7 +142,7 @@ async def deepfloydifdemo(ctx):
142
  async def jojodemo(ctx):
143
  try:
144
  thread = await ctx.message.create_thread(name=f'{ctx.author} Demo Thread')
145
- await thread.send(f'{ctx.author.mention}Here is a demo for the !jojo command!')
146
  await asyncio.sleep(0.5)
147
  await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113492260294770778/image.png')
148
  except Exception as e:
@@ -161,26 +161,29 @@ async def jojo(ctx):
161
  # safety checks?✅
162
  # bot no crash ✅
163
  try:
164
- if await safetychecks(ctx): #✅
165
- await ctx.message.add_reaction('🤖')
166
  await ctx.message.add_reaction('⏳')
167
  thread = await ctx.message.create_thread(name=f'{ctx.author} Jojo Thread')
168
  if ctx.message.attachments:
169
- await thread.send(f'{ctx.author.mention}Generating images in thread, can take ~1 minute...yare yare, daze ...')
170
  attachment = ctx.message.attachments[0]
171
  style = 'JoJo'
172
  #im = jojogan.predict(attachment.url, style)
173
  im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
174
  #await ctx.message.reply(f'Here is the {style} version of it', file=discord.File(im))
175
- await thread.send(f'{ctx.author.mention}Here is the {style} version of it', file=discord.File(im))
176
- await ctx.message.add_reaction('✅') # img + face
 
 
 
 
177
  else: # no image
178
- await thread.send(f"{ctx.author.mention}No attachments to be found...Can't animify dat! Try sending me an image 😉")
179
  await ctx.message.add_reaction('❌')
180
  await ctx.message.remove_reaction('⏳', bot.user)
181
  except Exception as e: # no generation / img + no face
182
  print(f"Error: {e}")
183
- await thread.send(f"{ctx.author.mention}Error: {e}")
184
  await ctx.message.add_reaction('❌')
185
  await ctx.message.remove_reaction('⏳', bot.user)
186
 
@@ -190,23 +193,23 @@ async def jojo(ctx):
190
  async def disney(ctx):
191
  try:
192
  if await safetychecks(ctx): #✅
193
- await ctx.message.add_reaction('🤖')
194
  await ctx.message.add_reaction('⏳')
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...')
198
  attachment = ctx.message.attachments[0]
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('✅') # img + face
 
203
  else: # no image
204
- await thread.send(f"{ctx.author.mention}No attachments to be found...Can't animify dat! Try sending me an image 😉")
205
  await ctx.message.add_reaction('❌')
206
  await ctx.message.remove_reaction('⏳', bot.user)
207
  except Exception as e: # no generation / img + no face
208
  print(f"Error: {e}")
209
- await thread.send(f"{ctx.author.mention}Error: {e}")
210
  await ctx.message.add_reaction('❌')
211
  await ctx.message.remove_reaction('⏳', bot.user)
212
 
@@ -215,24 +218,24 @@ async def disney(ctx):
215
  @bot.command()
216
  async def spidey(ctx):
217
  try:
218
- if await safetychecks(ctx): #✅
219
- await ctx.message.add_reaction('🤖')
220
  await ctx.message.add_reaction('⏳')
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...')
224
  attachment = ctx.message.attachments[0]
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('✅') # img + face
 
229
  else: # no image
230
- await thread.send(f"{ctx.author.mention}No attachments to be found...Can't animify dat! Try sending me an image 😉")
231
  await ctx.message.add_reaction('❌')
232
  await ctx.message.remove_reaction('⏳', bot.user)
233
  except Exception as e: # no generation / img + no face
234
  print(f"Error: {e}")
235
- await thread.send(f"{ctx.author.mention}Error: {e}")
236
  await ctx.message.add_reaction('❌')
237
  await ctx.message.remove_reaction('⏳', bot.user)
238
 
@@ -242,23 +245,23 @@ async def spidey(ctx):
242
  async def sketch(ctx):
243
  try:
244
  if await safetychecks(ctx): #✅
245
- await ctx.message.add_reaction('🤖')
246
  await ctx.message.add_reaction('⏳')
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...')
250
  attachment = ctx.message.attachments[0]
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('✅') # img + face
 
255
  else: # no image
256
- await thread.send(f"{ctx.author.mention}No attachments to be found...Can't animify dat! Try sending me an image 😉")
257
  await ctx.message.add_reaction('❌')
258
  await ctx.message.remove_reaction('⏳', bot.user)
259
  except Exception as e: # no generation / img + no face
260
  print(f"Error: {e}")
261
- await thread.send(f"{ctx.author.mention}Error: {e}")
262
  await ctx.message.add_reaction('❌')
263
  await ctx.message.remove_reaction('⏳', bot.user)
264
  #----------------------------------------------------------------------------------------------------------------------------------------------
@@ -303,7 +306,6 @@ async def deepfloydif(ctx, *, prompt: str):
303
  try:
304
  try:
305
  if await safetychecks(ctx): #✅
306
- await ctx.message.add_reaction('🤖')
307
  await ctx.message.add_reaction('⏳')
308
  dfif_command_message_id = ctx.message.id # we will use this in some magic later on
309
  thread = await ctx.message.create_thread(name=f'{ctx.author} DeepfloydIF Image Upscaling Thread ')
@@ -382,11 +384,11 @@ async def deepfloydif(ctx, *, prompt: str):
382
  combined_image.save(combined_image_path)
383
 
384
  with open(combined_image_path, 'rb') as f:
385
- combined_image_dfif = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale! \n 1️⃣ 2️⃣ \n 3️⃣ 4️⃣', file=discord.File(
386
  f, f'{partialpath}{dfif_command_message_id}.png')) # named something like: tmpgtv4qjix1111269940599738479.png
387
 
388
  #await thread.send(f'✅reacting with 1234...')
389
- emoji_list = ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
390
  await react1234(emoji_list, combined_image_dfif)
391
 
392
  ''' individual images
@@ -482,13 +484,13 @@ async def on_reaction_add(reaction, user): # ctx = await bot.get_context(reac
482
  #await reaction.message.channel.send(f"✅fullpath extracted, {fullpath}")
483
  emoji = reaction.emoji
484
 
485
- if emoji == "1️⃣":
486
  index = 0
487
- elif emoji == "2️⃣":
488
  index = 1
489
- elif emoji == "3️⃣":
490
  index = 2
491
- elif emoji == "4️⃣":
492
  index = 3
493
 
494
  #await reaction.message.channel.send(f"✅index extracted, {index}")
 
131
  async def deepfloydifdemo(ctx):
132
  try:
133
  thread = await ctx.message.create_thread(name=f'{ctx.author} Demo Thread')
134
+ await thread.send(f'{ctx.author.mention} Here is a demo for the !deepfloydif command!')
135
  await asyncio.sleep(0.5)
136
  await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113483403258499142/image.png')
137
  except Exception as e:
 
142
  async def jojodemo(ctx):
143
  try:
144
  thread = await ctx.message.create_thread(name=f'{ctx.author} Demo Thread')
145
+ await thread.send(f'{ctx.author.mention} Here is a demo for the !jojo command!')
146
  await asyncio.sleep(0.5)
147
  await thread.send(f'https://cdn.discordapp.com/attachments/932563860597121054/1113492260294770778/image.png')
148
  except Exception as e:
 
161
  # safety checks?✅
162
  # bot no crash ✅
163
  try:
164
+ if await safetychecks(ctx): #✅
 
165
  await ctx.message.add_reaction('⏳')
166
  thread = await ctx.message.create_thread(name=f'{ctx.author} Jojo Thread')
167
  if ctx.message.attachments:
168
+ await thread.send(f'{ctx.author.mention} Generating images in thread, can take ~1 minute...yare yare, daze ...')
169
  attachment = ctx.message.attachments[0]
170
  style = 'JoJo'
171
  #im = jojogan.predict(attachment.url, style)
172
  im = await asyncio.get_running_loop().run_in_executor(None, jojogan.predict, attachment.url, style)
173
  #await ctx.message.reply(f'Here is the {style} version of it', file=discord.File(im))
174
+ await thread.send(f'{ctx.author.mention} Here is the {style} version of it', file=discord.File(im))
175
+
176
+ #testing animated
177
+ # <a:hugging_spin:1102656012621713488>
178
+ await ctx.message.add_reaction('<a:hugging_spin:1102656012621713488>') # img + face
179
+ await ctx.message.remove_reaction('⏳', 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('⏳', 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('⏳', bot.user)
189
 
 
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...')
200
  attachment = ctx.message.attachments[0]
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('✅') # img + face
205
+ await ctx.message.remove_reaction('⏳', bot.user)
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('⏳', bot.user)
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('⏳', bot.user)
215
 
 
218
  @bot.command()
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...')
226
  attachment = ctx.message.attachments[0]
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('✅') # img + face
231
+ await ctx.message.remove_reaction('⏳', bot.user)
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('⏳', bot.user)
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('⏳', bot.user)
241
 
 
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...')
252
  attachment = ctx.message.attachments[0]
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('✅') # img + face
257
+ await ctx.message.remove_reaction('⏳', bot.user)
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('⏳', bot.user)
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('⏳', bot.user)
267
  #----------------------------------------------------------------------------------------------------------------------------------------------
 
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 ')
 
384
  combined_image.save(combined_image_path)
385
 
386
  with open(combined_image_path, 'rb') as f:
387
+ combined_image_dfif = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale!', file=discord.File(
388
  f, f'{partialpath}{dfif_command_message_id}.png')) # named something like: tmpgtv4qjix1111269940599738479.png
389
 
390
  #await thread.send(f'✅reacting with 1234...')
391
+ emoji_list = ['↖️', '↗️', '↙️', '↘️']
392
  await react1234(emoji_list, combined_image_dfif)
393
 
394
  ''' individual images
 
484
  #await reaction.message.channel.send(f"✅fullpath extracted, {fullpath}")
485
  emoji = reaction.emoji
486
 
487
+ if emoji == "↖️":
488
  index = 0
489
+ elif emoji == "↗️":
490
  index = 1
491
+ elif emoji == "↙️":
492
  index = 2
493
+ elif emoji == "↘️":
494
  index = 3
495
 
496
  #await reaction.message.channel.send(f"✅index extracted, {index}")