Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin] Add logging to serverlock #5073

Merged
merged 4 commits into from May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion redbot/cogs/admin/__init__.py
Expand Up @@ -2,4 +2,4 @@


def setup(bot):
bot.add_cog(Admin())
bot.add_cog(Admin(bot))
11 changes: 10 additions & 1 deletion redbot/cogs/admin/admin.py
Expand Up @@ -70,7 +70,9 @@
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)
Expand Down Expand Up @@ -504,6 +506,13 @@ async def serverlock(self, ctx: commands.Context):
@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()


Expand Down