lunarflu HF Staff commited on
Commit
ad3f8da
Β·
1 Parent(s): ed9ae6e

[safetychecks] added error messages, alert in case of SC failure

Browse files
Files changed (1) hide show
  1. app.py +33 -23
app.py CHANGED
@@ -43,29 +43,39 @@ async def on_ready():
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
- bot_member = ctx.guild.get_member(bot.user.id)
52
- if any(role.id == offline_bot_role_id for role in bot_member.roles):
53
- return False
54
-
55
- # check if the command is in the allowed channel(s)
56
- channel_id = 1100458786826747945
57
- if ctx.channel.id != 1100458786826747945:
58
- return False
59
-
60
- # check if the user has the required role(s)
61
- guild_id = 879548962464493619
62
- required_role_id = 900063512829755413 # @verified for now
63
- guild = bot.get_guild(guild_id)
64
- required_role = guild.get_role(required_role_id)
65
- if required_role not in ctx.author.roles:
66
- return False
67
-
68
- return True
 
 
 
 
 
 
 
 
 
 
69
  #----------------------------------------------------------------------------------------------------------------------------------------------
70
  # jojo
71
  @bot.command()
 
43
  bot.log_channel = bot.get_channel(1100458786826747945) # 1100458786826747945 = bot-test, 1107006391547342910 = lunarbot server
44
  #---------------------------------------------------------------------------------------------------------------------------------------------
45
  async def safetychecks(ctx):
46
+ try:
47
+ if ctx.author.bot:
48
+ print(f"Error: The bot is not allowed to use its own commands.")
49
+ return False
50
+
51
+ #βœ… check if the bot is offline
52
+ offline_bot_role_id = 1103676632667017266
53
+ bot_member = ctx.guild.get_member(bot.user.id)
54
+ if any(role.id == offline_bot_role_id for role in bot_member.roles):
55
+ print(f"Error: The bot is offline or under maintenance. (Remove the offline-bot role to bring it online)")
56
+ await ctx.message.reply(f"<@811235357663297546> testing ping, SC failed somewhere")
57
+ return False
58
+
59
+ #βœ… check if the command is in the allowed channel(s)
60
+ channel_id = 1100458786826747945
61
+ if ctx.channel.id != 1100458786826747945:
62
+ print(f"Error: This is not a permitted channel for that command. ({ctx.channel} is the correct channel)")
63
+ return False
64
+
65
+ #βœ… check if the user has the required role(s)
66
+ guild_id = 879548962464493619
67
+ required_role_id = 900063512829755413 # @verified for now
68
+ guild = bot.get_guild(guild_id)
69
+ required_role = guild.get_role(required_role_id)
70
+ if required_role not in ctx.author.roles:
71
+ print(f"Error: The user does not have the required role to use that command. ({required_role} is the correct role)")
72
+ return False
73
+
74
+ return True
75
+
76
+ except Exception as e:
77
+ print(f"Error: safetychecks failed somewhere, command will not continue.")
78
+ await ctx.message.reply(f"<@811235357663297546> SC failed somewhere")
79
  #----------------------------------------------------------------------------------------------------------------------------------------------
80
  # jojo
81
  @bot.command()