diff --git a/main.py b/main.py index 818c588..0d400e7 100644 --- a/main.py +++ b/main.py @@ -22,6 +22,9 @@ async def on_ready(): print(f"Connected to {len(bot.guilds)} servers with {len(bot.users)} users.") print(f"Invite link: {nextcord.utils.oauth_url(bot.user.id)}") print(f"{bot.user} is ready! Created by koz") + + await settings.check_whitelist(bot) + activity = nextcord.Activity( type=nextcord.ActivityType.playing, name=settings.bot_activity ) diff --git a/utils/settings.py b/utils/settings.py index a194893..b21c9ed 100644 --- a/utils/settings.py +++ b/utils/settings.py @@ -1,9 +1,19 @@ import os from dotenv import load_dotenv +import logging load_dotenv() bot_token = os.getenv("BOT_TOKEN", "No token found") bot_prefix = os.getenv("BOT_PREFIX", "!") bot_activity = os.getenv("BOT_ACTIVITY", "Palworld") steam_api_key = os.getenv("STEAM_API_KEY", "No key found") -bot_language = os.getenv("BOT_LANGUAGE", "en") \ No newline at end of file +bot_language = os.getenv("BOT_LANGUAGE", "en") +whitelist_check = os.getenv('GUILD_WHITELIST') + +async def check_whitelist(bot): + if whitelist_check: + wl_ids = [int(gid.strip()) for gid in whitelist_check.split(',')] + for guild in bot.guilds: + if guild.id not in wl_ids: + await guild.leave() + logging.info(f"Left {guild.name} (ID: {guild.id})") \ No newline at end of file