mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Admin] Add logging to serverlock (#5073)
Co-authored-by: Twentysix <Twentysix26@users.noreply.github.com>
This commit is contained in:
parent
2f7376169e
commit
982feda858
@ -2,4 +2,4 @@ from .admin import Admin
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Admin())
|
||||
bot.add_cog(Admin(bot))
|
||||
|
||||
@ -70,7 +70,9 @@ _ = T_
|
||||
class Admin(commands.Cog):
|
||||
"""A collection of server administration utilities."""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
self.config = Config.get_conf(self, 8237492837454039, force_registration=True)
|
||||
|
||||
self.config.register_global(serverlocked=False, schema_version=0)
|
||||
@ -504,6 +506,13 @@ class Admin(commands.Cog):
|
||||
@commands.Cog.listener()
|
||||
async def on_guild_join(self, guild: discord.Guild):
|
||||
if await self.config.serverlocked():
|
||||
if len(self.bot.guilds) == 1: # will be 0 once left
|
||||
log.warning(
|
||||
f"Leaving guild '{guild.name}' ({guild.id}) due to serverlock. You can "
|
||||
"temporarily disable serverlock by starting up the bot with the --no-cogs flag."
|
||||
)
|
||||
else:
|
||||
log.info(f"Leaving guild '{guild.name}' ({guild.id}) due to serverlock.")
|
||||
await guild.leave()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user