[safety checks] test
Browse files
app.py
CHANGED
@@ -36,41 +36,67 @@ intents.message_content = True
|
|
36 |
bot = commands.Bot(command_prefix='!', intents=intents)
|
37 |
|
38 |
|
39 |
-
|
40 |
-
|
41 |
@bot.event
|
42 |
async def on_ready():
|
43 |
print('Logged on as', bot.user)
|
44 |
bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
47 |
# jojo
|
48 |
@bot.command()
|
49 |
async def jojo(ctx):
|
50 |
-
# img + face
|
51 |
# img + no face β
|
52 |
-
# no image
|
53 |
# no generation β
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
await thread.send(f'{ctx.author.mention}Generating images in thread, can take ~1 minute...yare yare, daze ...')
|
59 |
-
|
60 |
-
attachment = ctx.message.attachments[0]
|
61 |
-
style = 'JoJo'
|
62 |
-
im = jojogan.predict(attachment.url, style)
|
63 |
-
#await ctx.message.reply(f'Here is the {style} version of it', file=discord.File(im))
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
await
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
76 |
# Disney
|
|
|
36 |
bot = commands.Bot(command_prefix='!', intents=intents)
|
37 |
|
38 |
|
39 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
40 |
@bot.event
|
41 |
async def on_ready():
|
42 |
print('Logged on as', bot.user)
|
43 |
bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
|
44 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------
|
45 |
+
async def safetychecks(ctx):
|
46 |
+
if ctx.author.bot:
|
47 |
+
return False
|
48 |
+
|
49 |
+
# check if the bot is offline
|
50 |
+
offline_bot_role_id = 1103676632667017266
|
51 |
+
if offline_bot_role_id in bot.roles:
|
52 |
+
return False
|
53 |
+
|
54 |
+
# check if the command is in the allowed channel(s)
|
55 |
+
channel = ctx.message.channel.id
|
56 |
+
if channel != 1100458786826747945:
|
57 |
+
return False
|
58 |
+
|
59 |
+
# check if the user has the required role(s)
|
60 |
+
guild = 879548962464493619
|
61 |
+
required_role_id = 900063512829755413 # @verified for now
|
62 |
+
required_role = guild.get_role(required_role_id)
|
63 |
+
if required_role not in ctx.author.roles:
|
64 |
+
return False
|
65 |
+
return True
|
66 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
67 |
# jojo
|
68 |
@bot.command()
|
69 |
async def jojo(ctx):
|
70 |
+
# img + face β
|
71 |
# img + no face β
|
72 |
+
# no image β
|
73 |
# no generation β
|
74 |
+
# responsive? β
|
75 |
+
# ratelimits? β
|
76 |
+
# safety checks?β
|
77 |
+
# bot no crash β
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
+
if await safetychecks:
|
80 |
+
try:
|
81 |
+
await ctx.message.add_reaction('π€')
|
82 |
+
thread = await ctx.message.create_thread(name=f'{ctx.author} Jojo Thread')
|
83 |
+
if ctx.message.attachments:
|
84 |
+
await thread.send(f'{ctx.author.mention}Generating images in thread, can take ~1 minute...yare yare, daze ...')
|
85 |
+
|
86 |
+
attachment = ctx.message.attachments[0]
|
87 |
+
style = 'JoJo'
|
88 |
+
im = jojogan.predict(attachment.url, style)
|
89 |
+
#await ctx.message.reply(f'Here is the {style} version of it', file=discord.File(im))
|
90 |
+
|
91 |
+
await thread.send(f'{ctx.author.mention}Here is the {style} version of it', file=discord.File(im))
|
92 |
+
await ctx.message.add_reaction('β
') # img + face
|
93 |
+
else: # no image
|
94 |
+
await thread.send(f"{ctx.author.mention}No attachments to be found...Can't animify dat! Try sending me an image π")
|
95 |
+
await ctx.message.add_reaction('β')
|
96 |
+
except Exception as e: # no generation / img + no face
|
97 |
+
print(f"Error: {e}")
|
98 |
+
await thread.send(f"{ctx.author.mention}Error: {e}")
|
99 |
+
await ctx.message.add_reaction('β')
|
100 |
|
101 |
#----------------------------------------------------------------------------------------------------------------------------------------------
|
102 |
# Disney
|