[tasks] moving stuff around
Browse files
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 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
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():
|