lunarflu HF Staff commited on
Commit
d48cc05
Β·
1 Parent(s): d11f62f

[tasks] moving stuff around

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -28,31 +28,30 @@ intents.message_content = True
28
  bot = commands.Bot(command_prefix='!', intents=intents)
29
 
30
  #---------------------------------------------------------------------------------------------------------------------------
31
- async def generate_jojo_image(ctx):
 
 
 
 
 
 
 
32
  if ctx.message.attachments:
33
  attachment = ctx.message.attachments[0]
34
  await ctx.message.add_reaction('πŸ€–')
35
  await ctx.message.add_reaction('βŒ›')
36
-
37
- style = 'JoJo'
38
- im = jojogan.predict(attachment.url, style)
39
- await ctx.send(f'{ctx.author.mention} Here is the {style} version of it')
40
- await ctx.send(file=discord.File(im))
 
41
 
42
  await ctx.message.remove_reaction('βŒ›', bot.user)
43
  await ctx.message.add_reaction('βœ…')
44
-
45
  else:
46
  await ctx.send(f"{ctx.author.mention} No attachments to be found... Can't animify dat! Try sending me an image πŸ˜‰")
47
  await ctx.message.add_reaction('❌')
48
-
49
- #----------------------------------------------------------------------------------------------------------------------------
50
- @bot.command()
51
- async def jojo(ctx):
52
-
53
- # task test
54
- task = asyncio.create_task(generate_jojo_image(ctx))
55
- await task
56
  #----------------------------------------------------------------------------------------------------------------------------
57
 
58
  def run_bot():
 
28
  bot = commands.Bot(command_prefix='!', intents=intents)
29
 
30
  #---------------------------------------------------------------------------------------------------------------------------
31
+ async def generate_jojo_image(ctx, attachment):
32
+ style = 'JoJo'
33
+ im = jojogan.predict(attachment.url, style)
34
+ await ctx.send(f'{ctx.author.mention} Here is the {style} version of it')
35
+ await ctx.send(file=discord.File(im))
36
+ #---------------------------------------------------------------------------------------------------------------------------
37
+ @bot.command()
38
+ async def jojo(ctx):
39
  if ctx.message.attachments:
40
  attachment = ctx.message.attachments[0]
41
  await ctx.message.add_reaction('πŸ€–')
42
  await ctx.message.add_reaction('βŒ›')
43
+
44
+ # Run the image generation asynchronously
45
+ task = asyncio.create_task(generate_jojo_image(ctx, attachment))
46
+
47
+ # Wait for the task to complete before proceeding
48
+ await task
49
 
50
  await ctx.message.remove_reaction('βŒ›', bot.user)
51
  await ctx.message.add_reaction('βœ…')
 
52
  else:
53
  await ctx.send(f"{ctx.author.mention} No attachments to be found... Can't animify dat! Try sending me an image πŸ˜‰")
54
  await ctx.message.add_reaction('❌')
 
 
 
 
 
 
 
 
55
  #----------------------------------------------------------------------------------------------------------------------------
56
 
57
  def run_bot():