removed debugging messages
Browse files
app.py
CHANGED
@@ -78,20 +78,16 @@ async def safetychecks(ctx):
|
|
78 |
offline_bot_role_id = 1103676632667017266
|
79 |
bot_member = ctx.guild.get_member(bot.user.id)
|
80 |
if any(role.id == offline_bot_role_id for role in bot_member.roles):
|
81 |
-
print(f"Error: The bot is offline or under maintenance. (Remove the offline-bot role to bring it online)")
|
82 |
-
return False
|
83 |
-
else:
|
84 |
-
await ctx.reply(f"✅{bot} is online")
|
85 |
|
86 |
#✅✅ check if the command is in the allowed channel(s)
|
87 |
bot_test = 1100458786826747945
|
88 |
testing_the_bot = 1113182673859518514
|
89 |
channel_id = testing_the_bot
|
90 |
if ctx.channel.id != channel_id: # #bot-test = 1100458786826747945, #testing-the-bot = 1113182673859518514
|
91 |
-
print(f"
|
92 |
-
return False
|
93 |
-
else:
|
94 |
-
await ctx.reply(f"✅{ctx.channel} is a valid channel for commands")
|
95 |
|
96 |
#✅✅ check if the user has the required role(s)
|
97 |
guild_id = 879548962464493619
|
@@ -99,11 +95,8 @@ async def safetychecks(ctx):
|
|
99 |
guild = bot.get_guild(guild_id)
|
100 |
required_role = guild.get_role(required_role_id)
|
101 |
if required_role not in ctx.author.roles:
|
102 |
-
print(f"Error:
|
103 |
-
await ctx.reply(f"❌{ctx.author} does not have the required role to use that command. ({required_role} is the correct role)")
|
104 |
return False
|
105 |
-
else:
|
106 |
-
await ctx.reply(f"✅{ctx.author} has the required role {required_role}")
|
107 |
|
108 |
return True
|
109 |
|
@@ -272,7 +265,7 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
272 |
|
273 |
except Exception as e:
|
274 |
print(f"Error: {e}")
|
275 |
-
await ctx.reply('stage 1 error -> pre generation')
|
276 |
await ctx.message.add_reaction('❌')
|
277 |
|
278 |
#generation✅-------------------------------------------------------
|
@@ -281,10 +274,10 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
281 |
# prompt, negative_prompt, seed, number_of_images, guidance_scale, custom_timesteps_1, number_of_inference_steps, api_name='/generate64')
|
282 |
|
283 |
# run blocking function in executor
|
284 |
-
await thread.send(f'✅running blocking function in executor')
|
285 |
loop = asyncio.get_running_loop()
|
286 |
result = await loop.run_in_executor(None, inference, prompt)
|
287 |
-
await thread.send(f'✅run_in_executor ran successfully')
|
288 |
stage_1_results = result[0]
|
289 |
stage_1_result_path = result[2]
|
290 |
|
@@ -292,11 +285,11 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
292 |
|
293 |
except Exception as e:
|
294 |
print(f"Error: {e}")
|
295 |
-
await ctx.reply('❌stage 1 error -> during generation')
|
296 |
await ctx.message.add_reaction('❌')
|
297 |
#posting images✅----------------------------------------------------------------
|
298 |
try:
|
299 |
-
await thread.send(f'✅combining images...')
|
300 |
png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
|
301 |
|
302 |
if png_files:
|
@@ -329,7 +322,7 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
329 |
combined_image_dfif = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale!', file=discord.File(
|
330 |
f, f'{partialpath}{dfif_command_message_id}.png')) # named something like: tmpgtv4qjix1111269940599738479.png
|
331 |
|
332 |
-
await thread.send(f'✅reacting with 1234...')
|
333 |
emoji_list = ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
|
334 |
await react1234(emoji_list, combined_image_dfif)
|
335 |
|
@@ -348,26 +341,26 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
348 |
|
349 |
except Exception as e:
|
350 |
print(f"Error: {e}")
|
351 |
-
await ctx.reply('❌stage 1 error -> posting images in thread')
|
352 |
await ctx.message.add_reaction('❌')
|
353 |
|
354 |
#deepfloydif try/except
|
355 |
except Exception as e:
|
356 |
print(f"Error: {e}")
|
357 |
-
await ctx.reply('❌An error occurred in stage 1 for deepfloydif')
|
358 |
await ctx.message.add_reaction('❌')
|
359 |
|
360 |
#----------------------------------------------------------------------------------------------------------------------------
|
361 |
# Stage 2 ✅
|
362 |
async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id): # add safetychecks
|
363 |
try:
|
364 |
-
await thread.send(f"✅inside dfif2, upscaling")
|
365 |
|
366 |
# run blocking function in executor
|
367 |
loop = asyncio.get_running_loop()
|
368 |
result_path = await loop.run_in_executor(None, inference2, index, stage_1_result_path)
|
369 |
|
370 |
-
await thread.send(f"✅upscale done")
|
371 |
with open(result_path, 'rb') as f:
|
372 |
await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
|
373 |
|
@@ -383,7 +376,7 @@ async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id
|
|
383 |
|
384 |
# reacting to original !deepfloydif command + using a custom emoji to do it
|
385 |
await dfif_command_message.add_reaction(confirm_emoji)
|
386 |
-
await thread.send(f"✅upscale posted")
|
387 |
#await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
|
388 |
#await ctx.message.add_reaction('✅') need to fix this
|
389 |
|
@@ -414,7 +407,7 @@ async def on_reaction_add(reaction, user): # ctx = await bot.get_context(reac
|
|
414 |
if reaction.message.attachments:
|
415 |
if user.id == reaction.message.mentions[0].id: # if user.id == reaction.message.mentions[0].id:
|
416 |
# magic begins
|
417 |
-
await reaction.message.channel.send("✅reaction detected")
|
418 |
attachment = reaction.message.attachments[0]
|
419 |
image_name = attachment.filename # named something like: tmpgtv4qjix1111269940599738479.png
|
420 |
# remove .png first
|
@@ -424,7 +417,7 @@ async def on_reaction_add(reaction, user): # ctx = await bot.get_context(reac
|
|
424 |
messageid = partialpathmessageid[11:] # 1111269940599738479
|
425 |
# add /tmp/ to partialpath, save as new variable
|
426 |
fullpath = "/tmp/" + partialpath # should be /tmp/tmpgtv4qjix
|
427 |
-
await reaction.message.channel.send(f"✅fullpath extracted, {fullpath}")
|
428 |
emoji = reaction.emoji
|
429 |
|
430 |
if emoji == "1️⃣":
|
@@ -436,13 +429,13 @@ async def on_reaction_add(reaction, user): # ctx = await bot.get_context(reac
|
|
436 |
elif emoji == "4️⃣":
|
437 |
index = 3
|
438 |
|
439 |
-
await reaction.message.channel.send(f"✅index extracted, {index}")
|
440 |
index = index
|
441 |
stage_1_result_path = fullpath
|
442 |
thread = reaction.message.channel
|
443 |
dfif_command_message_id = messageid
|
444 |
ctx = await bot.get_context(reaction.message)
|
445 |
-
await reaction.message.channel.send(f"✅calling dfif2")
|
446 |
await dfif2(index, stage_1_result_path, thread, dfif_command_message_id)
|
447 |
|
448 |
'''
|
|
|
78 |
offline_bot_role_id = 1103676632667017266
|
79 |
bot_member = ctx.guild.get_member(bot.user.id)
|
80 |
if any(role.id == offline_bot_role_id for role in bot_member.roles):
|
81 |
+
print(f"Error: {ctx.author} The bot is offline or under maintenance. (Remove the offline-bot role to bring it online)")
|
82 |
+
return False
|
|
|
|
|
83 |
|
84 |
#✅✅ check if the command is in the allowed channel(s)
|
85 |
bot_test = 1100458786826747945
|
86 |
testing_the_bot = 1113182673859518514
|
87 |
channel_id = testing_the_bot
|
88 |
if ctx.channel.id != channel_id: # #bot-test = 1100458786826747945, #testing-the-bot = 1113182673859518514
|
89 |
+
print(f"{ctx.author} commands are not permitted in {ctx.channel}")
|
90 |
+
return False
|
|
|
|
|
91 |
|
92 |
#✅✅ check if the user has the required role(s)
|
93 |
guild_id = 879548962464493619
|
|
|
95 |
guild = bot.get_guild(guild_id)
|
96 |
required_role = guild.get_role(required_role_id)
|
97 |
if required_role not in ctx.author.roles:
|
98 |
+
print(f"Error: {ctx.author} does not have the required role to use that command. ({required_role} is the correct role)")
|
|
|
99 |
return False
|
|
|
|
|
100 |
|
101 |
return True
|
102 |
|
|
|
265 |
|
266 |
except Exception as e:
|
267 |
print(f"Error: {e}")
|
268 |
+
#await ctx.reply('stage 1 error -> pre generation')
|
269 |
await ctx.message.add_reaction('❌')
|
270 |
|
271 |
#generation✅-------------------------------------------------------
|
|
|
274 |
# prompt, negative_prompt, seed, number_of_images, guidance_scale, custom_timesteps_1, number_of_inference_steps, api_name='/generate64')
|
275 |
|
276 |
# run blocking function in executor
|
277 |
+
#await thread.send(f'✅running blocking function in executor')
|
278 |
loop = asyncio.get_running_loop()
|
279 |
result = await loop.run_in_executor(None, inference, prompt)
|
280 |
+
#await thread.send(f'✅run_in_executor ran successfully')
|
281 |
stage_1_results = result[0]
|
282 |
stage_1_result_path = result[2]
|
283 |
|
|
|
285 |
|
286 |
except Exception as e:
|
287 |
print(f"Error: {e}")
|
288 |
+
#await ctx.reply('❌stage 1 error -> during generation')
|
289 |
await ctx.message.add_reaction('❌')
|
290 |
#posting images✅----------------------------------------------------------------
|
291 |
try:
|
292 |
+
#await thread.send(f'✅combining images...')
|
293 |
png_files = [f for f in os.listdir(stage_1_results) if f.endswith('.png')]
|
294 |
|
295 |
if png_files:
|
|
|
322 |
combined_image_dfif = await thread.send(f'{ctx.author.mention}React with the image number you want to upscale!', file=discord.File(
|
323 |
f, f'{partialpath}{dfif_command_message_id}.png')) # named something like: tmpgtv4qjix1111269940599738479.png
|
324 |
|
325 |
+
#await thread.send(f'✅reacting with 1234...')
|
326 |
emoji_list = ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
|
327 |
await react1234(emoji_list, combined_image_dfif)
|
328 |
|
|
|
341 |
|
342 |
except Exception as e:
|
343 |
print(f"Error: {e}")
|
344 |
+
#await ctx.reply('❌stage 1 error -> posting images in thread')
|
345 |
await ctx.message.add_reaction('❌')
|
346 |
|
347 |
#deepfloydif try/except
|
348 |
except Exception as e:
|
349 |
print(f"Error: {e}")
|
350 |
+
#await ctx.reply('❌An error occurred in stage 1 for deepfloydif')
|
351 |
await ctx.message.add_reaction('❌')
|
352 |
|
353 |
#----------------------------------------------------------------------------------------------------------------------------
|
354 |
# Stage 2 ✅
|
355 |
async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id): # add safetychecks
|
356 |
try:
|
357 |
+
#await thread.send(f"✅inside dfif2, upscaling")
|
358 |
|
359 |
# run blocking function in executor
|
360 |
loop = asyncio.get_running_loop()
|
361 |
result_path = await loop.run_in_executor(None, inference2, index, stage_1_result_path)
|
362 |
|
363 |
+
#await thread.send(f"✅upscale done")
|
364 |
with open(result_path, 'rb') as f:
|
365 |
await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
|
366 |
|
|
|
376 |
|
377 |
# reacting to original !deepfloydif command + using a custom emoji to do it
|
378 |
await dfif_command_message.add_reaction(confirm_emoji)
|
379 |
+
#await thread.send(f"✅upscale posted")
|
380 |
#await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
|
381 |
#await ctx.message.add_reaction('✅') need to fix this
|
382 |
|
|
|
407 |
if reaction.message.attachments:
|
408 |
if user.id == reaction.message.mentions[0].id: # if user.id == reaction.message.mentions[0].id:
|
409 |
# magic begins
|
410 |
+
#await reaction.message.channel.send("✅reaction detected")
|
411 |
attachment = reaction.message.attachments[0]
|
412 |
image_name = attachment.filename # named something like: tmpgtv4qjix1111269940599738479.png
|
413 |
# remove .png first
|
|
|
417 |
messageid = partialpathmessageid[11:] # 1111269940599738479
|
418 |
# add /tmp/ to partialpath, save as new variable
|
419 |
fullpath = "/tmp/" + partialpath # should be /tmp/tmpgtv4qjix
|
420 |
+
#await reaction.message.channel.send(f"✅fullpath extracted, {fullpath}")
|
421 |
emoji = reaction.emoji
|
422 |
|
423 |
if emoji == "1️⃣":
|
|
|
429 |
elif emoji == "4️⃣":
|
430 |
index = 3
|
431 |
|
432 |
+
#await reaction.message.channel.send(f"✅index extracted, {index}")
|
433 |
index = index
|
434 |
stage_1_result_path = fullpath
|
435 |
thread = reaction.message.channel
|
436 |
dfif_command_message_id = messageid
|
437 |
ctx = await bot.get_context(reaction.message)
|
438 |
+
#await reaction.message.channel.send(f"✅calling dfif2")
|
439 |
await dfif2(index, stage_1_result_path, thread, dfif_command_message_id)
|
440 |
|
441 |
'''
|