[stable everything] spiderverse >>> spidey, removed safetychecks from dfif2 (not needed), removed unnecessary parts from safetychecks, added !help
Browse files
app.py
CHANGED
|
@@ -60,6 +60,14 @@ async def on_ready():
|
|
| 60 |
print('Logged on as', bot.user)
|
| 61 |
bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
|
| 62 |
#---------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
async def safetychecks(ctx):
|
| 64 |
try:
|
| 65 |
if ctx.author.bot:
|
|
@@ -73,20 +81,14 @@ async def safetychecks(ctx):
|
|
| 73 |
print(f"Error: The bot is offline or under maintenance. (Remove the offline-bot role to bring it online)")
|
| 74 |
return False
|
| 75 |
else:
|
| 76 |
-
await ctx.
|
| 77 |
|
| 78 |
#✅✅ check if the command is in the allowed channel(s)
|
| 79 |
channel_id = 1100458786826747945
|
| 80 |
if ctx.channel.id != channel_id: # #bot-test = 1100458786826747945
|
| 81 |
print(f"If using a command, commands are not permitted in {ctx.channel}")
|
| 82 |
-
thread = ctx.channel
|
| 83 |
-
if thread.parent_id != channel_id: # threads have different channel_ids than their parents
|
| 84 |
-
print(f"Error: {thread} is not a permitted thread for upscaling.")
|
| 85 |
-
return False
|
| 86 |
-
else:
|
| 87 |
-
await ctx.channel.send(f"✅{thread} is a valid thread for upscaling")
|
| 88 |
else:
|
| 89 |
-
await ctx.
|
| 90 |
|
| 91 |
#✅✅ check if the user has the required role(s)
|
| 92 |
guild_id = 879548962464493619
|
|
@@ -97,7 +99,7 @@ async def safetychecks(ctx):
|
|
| 97 |
print(f"Error: The user does not have the required role to use that command. ({required_role} is the correct role)")
|
| 98 |
return False
|
| 99 |
else:
|
| 100 |
-
await ctx.
|
| 101 |
|
| 102 |
return True
|
| 103 |
|
|
@@ -164,7 +166,7 @@ async def disney(ctx):
|
|
| 164 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
| 165 |
# Spider-Verse ✅
|
| 166 |
@bot.command()
|
| 167 |
-
async def
|
| 168 |
try:
|
| 169 |
if await safetychecks(ctx): #✅
|
| 170 |
await ctx.message.add_reaction('🤖')
|
|
@@ -353,34 +355,33 @@ async def deepfloydif(ctx, *, prompt: str):
|
|
| 353 |
|
| 354 |
#----------------------------------------------------------------------------------------------------------------------------
|
| 355 |
# Stage 2 ✅
|
| 356 |
-
async def dfif2(
|
| 357 |
try:
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
await
|
| 382 |
-
|
| 383 |
-
#await ctx.message.add_reaction('✅') need to fix this
|
| 384 |
|
| 385 |
'''
|
| 386 |
try:
|
|
@@ -398,7 +399,7 @@ async def dfif2(ctx, index: int, stage_1_result_path, thread, dfif_command_messa
|
|
| 398 |
@bot.event
|
| 399 |
async def on_reaction_add(reaction, user): # ctx = await bot.get_context(reaction.message)? could try later, might simplify
|
| 400 |
try:
|
| 401 |
-
ctx = await bot.get_context(reaction.message)
|
| 402 |
# safety checks first ❌
|
| 403 |
thread = reaction.message.channel
|
| 404 |
threadparentid = thread.parent.id
|
|
|
|
| 60 |
print('Logged on as', bot.user)
|
| 61 |
bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
|
| 62 |
#---------------------------------------------------------------------------------------------------------------------------------------------
|
| 63 |
+
@bot.command()
|
| 64 |
+
async def help(ctx):
|
| 65 |
+
try:
|
| 66 |
+
if await safetychecks(ctx):
|
| 67 |
+
await ctx.reply(f"Use !jojo !disney !spidey or !sketch. Have fun! 🤗💖")
|
| 68 |
+
except Exception as e:
|
| 69 |
+
print(f"Error: unable to help :(")
|
| 70 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------
|
| 71 |
async def safetychecks(ctx):
|
| 72 |
try:
|
| 73 |
if ctx.author.bot:
|
|
|
|
| 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 |
channel_id = 1100458786826747945
|
| 88 |
if ctx.channel.id != channel_id: # #bot-test = 1100458786826747945
|
| 89 |
print(f"If using a command, commands are not permitted in {ctx.channel}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
else:
|
| 91 |
+
await ctx.reply(f"✅{ctx.channel} is a valid channel for commands")
|
| 92 |
|
| 93 |
#✅✅ check if the user has the required role(s)
|
| 94 |
guild_id = 879548962464493619
|
|
|
|
| 99 |
print(f"Error: The user does not have the required role to use that command. ({required_role} is the correct role)")
|
| 100 |
return False
|
| 101 |
else:
|
| 102 |
+
await ctx.reply(f"✅{ctx.author} has the required role {required_role}")
|
| 103 |
|
| 104 |
return True
|
| 105 |
|
|
|
|
| 166 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
| 167 |
# Spider-Verse ✅
|
| 168 |
@bot.command()
|
| 169 |
+
async def spidey(ctx):
|
| 170 |
try:
|
| 171 |
if await safetychecks(ctx): #✅
|
| 172 |
await ctx.message.add_reaction('🤖')
|
|
|
|
| 355 |
|
| 356 |
#----------------------------------------------------------------------------------------------------------------------------
|
| 357 |
# Stage 2 ✅
|
| 358 |
+
async def dfif2(index: int, stage_1_result_path, thread, dfif_command_message_id): # add safetychecks
|
| 359 |
try:
|
| 360 |
+
await thread.send(f"✅inside dfif2, upscaling")
|
| 361 |
+
|
| 362 |
+
# run blocking function in executor
|
| 363 |
+
loop = asyncio.get_running_loop()
|
| 364 |
+
result_path = await loop.run_in_executor(None, inference2, index)
|
| 365 |
+
|
| 366 |
+
await thread.send(f"✅upscale done")
|
| 367 |
+
with open(result_path, 'rb') as f:
|
| 368 |
+
await thread.send(f'Here is the upscaled image! :) ', file=discord.File(f, 'result.png'))
|
| 369 |
+
|
| 370 |
+
# using custom emoji that looks nicer
|
| 371 |
+
emoji_guild = thread.guild
|
| 372 |
+
confirm_emoji_id = 1098629085955113011
|
| 373 |
+
confirm_emoji = discord.utils.get(emoji_guild.emojis, id=confirm_emoji_id)
|
| 374 |
+
|
| 375 |
+
# assuming dfif2 is always inside a thread, we can always exit the thread to find the channel with the original command,
|
| 376 |
+
# which allows us to react confirm on that message.
|
| 377 |
+
parent_channel = thread.parent
|
| 378 |
+
dfif_command_message = await parent_channel.fetch_message(dfif_command_message_id)
|
| 379 |
+
|
| 380 |
+
# reacting to original !deepfloydif command + using a custom emoji to do it
|
| 381 |
+
await dfif_command_message.add_reaction(confirm_emoji)
|
| 382 |
+
await thread.send(f"✅upscale posted")
|
| 383 |
+
#await ctx.reply('Here is the result of the second stage', file=discord.File(f, 'result.png'))
|
| 384 |
+
#await ctx.message.add_reaction('✅') need to fix this
|
|
|
|
| 385 |
|
| 386 |
'''
|
| 387 |
try:
|
|
|
|
| 399 |
@bot.event
|
| 400 |
async def on_reaction_add(reaction, user): # ctx = await bot.get_context(reaction.message)? could try later, might simplify
|
| 401 |
try:
|
| 402 |
+
#ctx = await bot.get_context(reaction.message)
|
| 403 |
# safety checks first ❌
|
| 404 |
thread = reaction.message.channel
|
| 405 |
threadparentid = thread.parent.id
|