[safetychecks] added error messages, alert in case of SC failure
Browse files
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 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|