Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
except ImportError:
pass

from core import checks
from core import checks, migrations
from core.changelog import Changelog
from core.clients import ApiClient, MongoDBClient, PluginDatabaseClient
from core.config import ConfigManager
Expand Down Expand Up @@ -576,12 +576,18 @@ async def on_ready(self):
)
logger.line()

# Check if the legacy blocklist is being used
if len(self.config["blocked"]) > 0 or len(self.config["blocked_roles"]) > 0:
logger.warning(
"Un-migrated blocklists found. Please run the '[p]migrate blocklist' command after backing "
"up your config/database. Blocklist functionality will be disabled until this is done."
)
logger.line()
# This should only run in the host has decided on it, which is why it's environment variable based
if "UNATTENDED_MIGRATION" in os.environ.items() and os.environ["UNATTENDED_MIGRATION"].lower() == "true":
logger.info("running unattended blocklist migration")
await migrations.migrate_blocklist(self)
else:
logger.warning(
"Un-migrated blocklists found. Please run the '[p]migrate blocklist' command after backing "
"up your config/database. Blocklist functionality will be disabled until this is done."
)
logger.line()

await self.threads.populate_cache()

Expand Down
9 changes: 9 additions & 0 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,15 @@ async def autotrigger_list(self, ctx):
async def migrate(self, ctx, migration: str):
"""Perform a given database migration"""
if migration == "blocklist":
if not len(self.bot.config["blocked"]) > 0 and not len(self.bot.config["blocked_roles"]) > 0:
await ctx.send(
embed=discord.Embed(title="Error",
description="No blocked users or roles can be migrated.\n\n "
"You don't need to migrated the blocklist as it's "
"already been done or there is nothing to migrate.",
color=self.bot.error_color)
)
return
try:
await migrations.migrate_blocklist(self.bot)
except Exception as e:
Expand Down