Skip to content

Commit

Permalink
Optional Guild Whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoz committed Aug 14, 2024
1 parent 2f61912 commit 58dfcbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
12 changes: 11 additions & 1 deletion utils/settings.py
Original file line number Diff line number Diff line change
@@ -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")
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})")

0 comments on commit 58dfcbf

Please sign in to comment.