lunarflu HF Staff commited on
Commit
b76c726
Β·
1 Parent(s): b7e73d9

[safety checks] test

Browse files
Files changed (1) hide show
  1. app.py +50 -24
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
- try:
55
- await ctx.message.add_reaction('πŸ€–')
56
- thread = await ctx.message.create_thread(name=f'{ctx.author} Jojo Thread')
57
- if ctx.message.attachments:
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
- await thread.send(f'{ctx.author.mention}Here is the {style} version of it', file=discord.File(im))
66
- await ctx.message.add_reaction('βœ…') # img + face
67
- else: # no image
68
- await thread.send(f"{ctx.author.mention}No attachments to be found...Can't animify dat! Try sending me an image πŸ˜‰")
69
- await ctx.message.add_reaction('❌')
70
- except Exception as e: # no generation / img + no face
71
- print(f"Error: {e}")
72
- await thread.send(f"{ctx.author.mention}Error: {e}")
73
- await ctx.message.add_reaction('❌')
 
 
 
 
 
 
 
 
 
 
 
 
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